C and C++


LANG.STRUCT.USING.DIRECTIVE : Using Directive

Summary

An occurrence of a using directive.

This class is a strict superset of Using Directive in Header File.

Properties

Class Name Using Directive
Significance style
Mnemonic LANG.STRUCT.USING.DIRECTIVE
Categories
AUTOSARC++14 AUTOSARC++14:M7-3-4 Using-directives shall not be used.
MisraC++2008 MisraC++2008:7-3-4 using-directives shall not be used.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Using Directive"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

namespace ns_directive{
  int dirA;
  int dirB;
}

namespace ns_declaration{
  int declA;
  int declB;
}

namespace ns_qualified{
  int qualA;
  int qualB;
}

using namespace ns_directive;  /* 'Using Directive' warning issued here */

using ns_declaration::declA;                 /* ok: using declaration (not directive) */

void lang_struct_using_directive(){
  ++dirA;
  ++declA;
  ++ns_qualified::qualA;                     /* ok: qualified identifier */
}

Relevant Configuration File Parameters

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