AutosarC++18_03-A1.1.1

All code shall conform to ISO/IEC 14882:2014 - Programming Language C++ and shall not use deprecated features

Required inputs: IR

Rationale

The current version of the C++ language is as defined by the ISO International Standard ISO/IEC 14822:2014(E) "Information technology - Programming languages - C++".

The C++14 is the improved version of the C++11. It is also “the state of the art” of C++ development that is required by ISO 26262 standard [5].

Any reference in this document to “C++ Language Standard” refers to the ISO/IEC 14822:2014 standard.

Note that all of the deprecated features of C++ Language Standard are defined in ISO/IEC 14882:2014 - Programming Language C++ Annexes C “Compatibility” and D “Compatibility features”.

Example
//% $Id: A1-1-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
#include <stdexcept>
void F(std::int32_t i) {
  std::int32_t *a = nullptr;

  // __try // Non-compliant - __try is a part of Visual Studio extension
  try // Compliant - try keyword is a part of C++ Language Standard
  {
    a = new std::int32_t[i];
    // ...
  }

  // __finally // Non-compliant - __finally is a part of Visual Studio
  // extension
  catch (std::exception &) // Compliant - C++ Language Standard does not define
                           // finally block, only try and catch blocks
  {
    delete[] a;
    a = nullptr;
  }
}
See Also
  • MISRA C++ 2008 [6]: 1-0-1 All code shall conform to ISO/IEC 14882:2003 “The C++ Standard Incorporating Technical Corrigendum 1”
  • JSF December 2005 [7]: 4.4.1 All code shall conform to ISO/IEC 14882:2002(E) standard C++.
  • HIC++ v4.0 [8]: 1.1.1 Ensure that code complies with the 2011 ISO C++ Language Standard.
  • HIC++ v4.0 [8]: 1.3.4 Do not use deprecated STL library features.

Possible Messages

Key

Text

Severity

Disabled

access_control

Number of access control declarations is higher than translation limit (limit: {}, actual value: {})

None

False

at_quick_exit_functions

Number of functions registered with at_quick_exit() is higher than translation limit (limit: {}, actual value: {})

None

False

atexit_functions

Number of functions registered with atexit() is higher than translation limit (limit: {}, actual value: {})

None

False

base_classes

Number of direct and indirect base classes is higher than translation limit (limit: {}, actual value: {})

None

False

cafe_message

{}

None

False

call_arguments

Number of arguments is higher than translation limit (limit: {}, actual value: {})

None

False

catch_handlers

Number of catch handlers is higher than translation limit (limit: {}, actual value: {})

None

False

chars_in_line

Number of characters in logical line is higher than translation limit (limit: {}, actual value: {})

None

False

chars_in_string

Number of characters in string is higher than translation limit (limit: {}, actual value: {})

None

False

clauses_braced_init_list

Number of initializer-clauses in braced-init-list is higher than translation limit (limit: {}, actual value: {})

None

False

cpp_members

Number of members is higher than translation limit (limit: {}, actual value: {})

None

False

data_members

Number of data members is higher than translation limit (limit: {}, actual value: {})

None

False

direct_bases

Number of direct base classes is higher than translation limit (limit: {}, actual value: {})

None

False

enumerators

Number of enumerators is higher than translation limit (limit: {}, actual value: {})

None

False

expr_in_core_constant

Number of full expressions evaluated within a core constant expression is higher than translation limit (limit: {}, actual value: {})

None

False

external_identifiers

Number of external identifiers in this unit is higher than translation limit (limit: {}, actual value: {})

None

False

final_virtual_functions

Number of final overriding virtual functions is higher than translation limit (limit: {}, actual value: {})

None

False

friends

Number of friend declarations is higher than translation limit (limit: {}, actual value: {})

None

False

function_parameters

Number of parameters is higher than translation limit (limit: {}, actual value: {})

None

False

lambda_captures

Number of lambda-captures in lambda-expression is higher than translation limit (limit: {}, actual value: {})

None

False

macro_arguments

Number of macro arguments is higher than translation limit (limit: {}, actual value: {})

None

False

macro_parameters

Number of macro parameters is higher than translation limit (limit: {}, actual value: {})

None

False

macros

Number of macro definitions in this unit is higher than translation limit (limit: {}, actual value: {})

None

False

member_initializers

Number of member initializers is higher than translation limit (limit: {}, actual value: {})

None

False

nested_blocks

Number of nested blocks is higher than translation limit (limit: {}, actual value: {})

None

False

nested_composites

Nesting level of structs and unions is higher than translation limit (limit: {}, actual value: {})

None

False

nested_declarators

Number of pointer/array/function declarators is higher than translation limit (limit: {}, actual value: {})

None

False

nested_externals

Number of nested external specifications is higher than translation limit (limit: {}, actual value: {})

None

False

nested_includes

Nesting level of #includes is higher than translation limit (limit: {}, actual value: {})

None

False

nested_preprocessor_ifs

Nesting level of #if is higher than translation limit (limit: {}, actual value: {})

None

False

nested_template_instantiations

Number of nested template instantiations is higher than translation limit (limit: {}, actual value: {})

None

False

object_size

Number of bytes in object is higher than translation limit (limit: {}, actual value: {})

None

False

parenthesized_declarators

Nesting level of parenthesized declarators is higher than translation limit (limit: {}, actual value: {})

None

False

parenthesized_expressions

Nesting level of parenthesized subexpressions is higher than translation limit (limit: {}, actual value: {})

None

False

placeholders

Number of placeholders is higher than translation limit (limit: {}, actual value: {})

None

False

recursive_constexpr

Number of recursive constexpr function invocations is higher than translation limit (limit: {}, actual value: {})

None

False

scope_qualifications

Number of scope qualifications is higher than translation limit (limit: {}, actual value: {})

None

False

significant_chars_external

Number of significant initial characters for external identifier is higher than translation limit (limit: {}, actual value: {})

None

False

significant_chars_internal

Number of significant initial characters for internal identifier is higher than translation limit (limit: {}, actual value: {})

None

False

static_members

Number of static members is higher than translation limit (limit: {}, actual value: {})

None

False

std_compile

You have to compile with option {}

None

False

structured_bindings

Number of structured bindings introduced in declaration is higher than translation limit (limit: {}, actual value: {})

None

False

switch_cases

Number of cases is higher than translation limit (limit: {}, actual value: {})

None

False

template_params

Number of template parameters is higher than translation limit (limit: {}, actual value: {})

None

False

throw_spec

Number of throw specifications is higher than translation limit (limit: {}, actual value: {})

None

False

variables_in_block

Number of variables in block is higher than translation limit (limit: {}, actual value: {})

None

False

virtual_bases

Number of virtual base classes is higher than translation limit (limit: {}, actual value: {})

None

False

Options

message_predicate

message_predicate : typing.Callable[[Cafe_Message], bool] | None = None

If provided, a custom predicate to filter relevant messages. Receives the message node and should return True for messages to report.
 

reported_messages

reported_messages

Type: set[int] | None

Default: {1215, 1444, 1909, 2221, 2381, 2464, 2465, 2567, 2802, 2914, 3015, 3018, 3019, 3020, 3021, 3022, 3299, 3300, 3301, 3302, 3303, 3304, 708}

If provided, only messages of these types are reported.
 

reported_severities

reported_severities : set[str] = {'error', 'warning'}

List of severities to display.
 

standards

standards : list[str] = ['--strict', '-A', '--strict_warnings']

List of allowed frontend (i.e. cafe) command-line options to select language standard.

I.e. instead of setting it to -std=c99, you have to set it to --c99, or instead of setting it to /std:c11, you have to set it to --c11.

 

use_error_number

use_error_number : bool = False

Whether the error number from the frontend should be used.
 

use_rule_severity

use_rule_severity : bool = True

Whether the rule's severity or the compiler's severity should be used.