-
Notifications
You must be signed in to change notification settings - Fork 76
Initial implementation of rule 4-1-1, must be standard C++17 #1106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
40ed471
9271829
8ef8017
20b5bf6
9b070a0
0441ef7
2c2ec86
9a4bb8b
634f4b3
e33289f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
|
|
||
| newtype Toolchain2Query = TCompilerLanguageExtensionsUsedQuery() | ||
|
|
||
| predicate isToolchain2QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `compilerLanguageExtensionsUsed` query | ||
| Toolchain2Package::compilerLanguageExtensionsUsedQuery() and | ||
| queryId = | ||
| // `@id` for the `compilerLanguageExtensionsUsed` query | ||
| "cpp/misra/compiler-language-extensions-used" and | ||
| ruleId = "RULE-4-1-1" and | ||
| category = "required" | ||
| } | ||
|
|
||
| module Toolchain2Package { | ||
| Query compilerLanguageExtensionsUsedQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `compilerLanguageExtensionsUsed` query | ||
| TQueryCPP(TToolchain2PackageQuery(TCompilerLanguageExtensionsUsedQuery())) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,20 @@ template <typename T, unsigned int N> struct remove_extent<T[N]> { | |||||||||||||||||||||||||||||||||||||
| typedef T type; | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| template <typename T> struct is_abstract { | ||||||||||||||||||||||||||||||||||||||
| const static bool value = false; | ||||||||||||||||||||||||||||||||||||||
| constexpr operator bool() { return value; } | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| template <typename T> bool is_abstract_v = is_abstract<T>::value; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| template <typename T, typename U> struct is_same { | ||||||||||||||||||||||||||||||||||||||
| const static bool value = false; | ||||||||||||||||||||||||||||||||||||||
| constexpr operator bool() { return value; } | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| template <typename T, typename U> bool is_same_v = is_same<T, U>::value; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+77
|
||||||||||||||||||||||||||||||||||||||
| template <typename T> bool is_abstract_v = is_abstract<T>::value; | |
| template <typename T, typename U> struct is_same { | |
| const static bool value = false; | |
| constexpr operator bool() { return value; } | |
| }; | |
| template <typename T, typename U> bool is_same_v = is_same<T, U>::value; | |
| template <typename T> | |
| inline constexpr bool is_abstract_v = is_abstract<T>::value; | |
| template <typename T, typename U> struct is_same { | |
| const static bool value = false; | |
| constexpr operator bool() { return value; } | |
| }; | |
| template <typename T, typename U> | |
| inline constexpr bool is_same_v = is_same<T, U>::value; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * @id cpp/misra/compiler-language-extensions-used | ||
| * @name RULE-4-1-1: A program shall conform to ISO/IEC 14882:2017 (C++17) | ||
| * @description Language extensions are compiler-specific features that are not part of the C++17 | ||
| * standard. Using these extensions reduces portability and may lead to unpredictable | ||
| * behavior when code is compiled with different compilers or compiler versions. | ||
| * @kind problem | ||
| * @precision high | ||
| * @problem.severity error | ||
| * @tags external/misra/id/rule-4-1-1 | ||
| * scope/system | ||
| * maintainability | ||
| * portability | ||
| * external/misra/enforcement/undecidable | ||
| * external/misra/obligation/required | ||
| */ | ||
|
|
||
| import cpp | ||
| import codingstandards.cpp.misra | ||
| import codingstandards.cpp.Extensions | ||
| import codingstandards.cpp.AlertReporting | ||
|
|
||
| from Element unwrapped, CPPCompilerExtension e | ||
| where | ||
| not isExcluded([e, unwrapped], Toolchain2Package::compilerLanguageExtensionsUsedQuery()) and | ||
| unwrapped = MacroUnwrapper<CPPCompilerExtension>::unwrapElement(e) | ||
| select unwrapped, e.getMessage() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| | test.cpp:11:3:11:19 | maybe_unused | Use of attribute 'maybe_unused' in namespace 'gnu' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:12:16:12:22 | aligned | Use of attribute 'aligned' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:13:16:13:21 | unused | Use of attribute 'unused' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:14:21:14:28 | noreturn | Use of attribute 'noreturn' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:15:3:15:17 | deprecated | Use of attribute 'deprecated' in namespace 'gnu' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:16:3:16:23 | nonstandard_attribute | Use of unrecognized or non-C++17 attribute 'nonstandard_attribute'. | | ||
| | test.cpp:19:3:19:20 | call to __builtin_popcount | Call to builtin function '__builtin_popcount' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:20:3:20:18 | call to __builtin_expect | Call to builtin function '__builtin_expect' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:21:3:21:22 | call to __sync_fetch_and_add_4 | Call to builtin function '__sync_fetch_and_add_4' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:23:3:23:20 | __is_abstract | Use of built-in operation '__is_abstract' is a compiler extension. | | ||
| | test.cpp:24:3:24:22 | __is_same | Use of built-in operation '__is_same' is a compiler extension. | | ||
| | test.cpp:30:3:33:4 | (statement expression) | Statement expressions are a compiler extension and are not portable to other compilers. | | ||
| | test.cpp:34:3:34:12 | ... ? ... : ... | Ternaries with omitted middle operands are a compiler extension and are not portable to other compilers. | | ||
| | test.cpp:36:12:36:13 | definition of l0 | Declaration of variable 'l0' as type '__int128' requires a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:45:20:45:30 | fallthrough | Use of attribute 'fallthrough' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:47:7:47:22 | fallthrough | Use of attribute 'fallthrough' in namespace 'gnu' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:55:3:55:29 | __builtin_va_start | Use of built-in operation '__builtin_va_start' is a compiler extension. | | ||
| | test.cpp:60:7:60:8 | definition of m1 | Declaration of variable 'm1' as a zero-length array (of 'int') requires a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:64:31:64:41 | vector_size | Use of attribute 'vector_size' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:66:1:66:20 | #ifdef __has_builtin | Call to builtin preprocessor feature '__has_builtin' is a compiler extension and is not portable to other compilers. | | ||
| | test.cpp:72:1:72:12 | #pragma once | Use of non-standard preprocessor directive '#pragma once' is a compiler extension. | | ||
| | test.cpp:73:1:73:27 | #pragma GCC diagnostic push | Use of non-standard preprocessor directive '#pragma GCC diagnostic push' is a compiler extension. | | ||
| | test.cpp:74:1:74:28 | #warning "This is a warning" | Use of non-standard preprocessor directive '#warning' is a compiler extension. | | ||
| | test.cpp:76:1:76:40 | #warning "preceding spaces is common" | Use of non-standard preprocessor directive '#warning' is a compiler extension. | | ||
| | test.cpp:81:7:81:7 | VLA declaration | Variable length array (used in 'VLA declaration') are a compiler extension and are not portable to other compilers. | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rules/RULE-4-1-1/CompilerLanguageExtensionsUsed.ql |
Uh oh!
There was an error while loading. Please reload this page.