Skip to content

Commit 4b54a05

Browse files
committed
Fix FP for issue 232
exclude pragmas rule A16-0-1
1 parent 1c9286b commit 4b54a05

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

cpp/autosar/src/rules/A16-0-1/PreProcessorShallOnlyBeUsedForCertainDirectivesPatterns.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ class AcceptableWrapper extends PreprocessorBranch {
8080

8181
from PreprocessorDirective directive, string message
8282
where
83-
(
84-
not directive instanceof PermittedDirectiveType and
85-
not directive instanceof AcceptableWrapper and
86-
message = "Preprocessor directive used for conditional compilation."
87-
) and
83+
//special exception case - pragmas already reported by A16-7-1
84+
not directive instanceof PreprocessorPragma and
85+
not directive instanceof PermittedDirectiveType and
86+
not directive instanceof AcceptableWrapper and
87+
message = "Preprocessor directive used for conditional compilation." and
8888
not isExcluded(directive,
8989
MacrosPackage::preProcessorShallOnlyBeUsedForCertainDirectivesPatternsQuery())
9090
select directive, message

cpp/autosar/test/rules/A16-0-1/PreProcessorShallOnlyBeUsedForCertainDirectivesPatterns.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
| test.cpp:3:1:3:25 | #pragma gcc testingpragma | Preprocessor directive used for conditional compilation. |
21
| test.cpp:5:1:5:18 | #ifndef TESTHEADER | Preprocessor directive used for conditional compilation. |
32
| test.cpp:9:1:9:26 | #define OBJECTLIKE_MACRO 1 | Preprocessor directive used for conditional compilation. |
43
| test.cpp:10:1:10:35 | #define FUNCTIONLIKE_MACRO(X) X + 1 | Preprocessor directive used for conditional compilation. |

cpp/autosar/test/rules/A16-0-1/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <string> //COMPLIANT
22

3-
#pragma gcc testingpragma // NON_COMPLIANT
3+
#pragma gcc testingpragma // COMPLIANT - exception - already reported by A16-7-1
44

55
#ifndef TESTHEADER // NON_COMPLIANT
66
int g;

0 commit comments

Comments
 (0)