-
Notifications
You must be signed in to change notification settings - Fork 67
Implement C Declarations5 package #146
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5cfc67
Declarations5: add RULE-8-5
knewbury01 0c2f3d5
Declarations5: add RULE-5-2
knewbury01 f866dd5
Declarations5: add RULE-8-8
knewbury01 654f9fa
Declarations5: add RULE-8-9
knewbury01 872ea18
Declarations5: address review comments
knewbury01 a08270e
Declarations5: finish adding shared rule for RULE-8-8
knewbury01 855de3c
Merge branch 'main' into knewbury01/Declarations5
knewbury01 3f3a73f
Merge branch 'main' into knewbury01/Declarations5
knewbury01 314a239
Merge branch 'main' into knewbury01/Declarations5
3b9c51d
Declarations5: fix shared query structure
knewbury01 e9b606d
Merge branch 'knewbury01/Declarations5' of https://github.com/knewbur…
knewbury01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ierfunctionredeclarationshared/MissingStaticSpecifierFunctionRedeclarationShared.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| test.c:2:6:2:7 | definition of f1 | The redeclaration of $@ with internal linkage misses the static specifier. | test.c:1:13:1:14 | declaration of f1 | function | |
2 changes: 2 additions & 0 deletions
2
...specifierfunctionredeclarationshared/MissingStaticSpecifierFunctionRedeclarationShared.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// GENERATED FILE - DO NOT MODIFY | ||
import codingstandards.cpp.rules.missingstaticspecifierfunctionredeclarationshared.MissingStaticSpecifierFunctionRedeclarationShared |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...exposedidentifierdeclarationshared/UnnecessaryExposedIdentifierDeclarationShared.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
| test.c:4:12:4:13 | g2 | The declaration g2 should be moved from the global namespace scope$@ into the $@ too minimize its visibility. | file://:0:0:0:0 | (global namespace) | scope | test.c:59:11:59:25 | { ... } | scope | | ||
| test.c:7:7:7:7 | j | The declaration j should be moved from $@ into the $@ too minimize its visibility. | test.c:6:11:13:1 | { ... } | scope | test.c:8:13:12:3 | { ... } | scope | | ||
| test.c:62:7:62:7 | i | The declaration i should be moved from $@ into the $@ too minimize its visibility. | test.c:61:11:71:1 | { ... } | scope | test.c:64:13:70:3 | { ... } | scope | | ||
| test.c:73:8:73:9 | S1 | The declaration S1 should be moved from the global namespace scope$@ into the $@ too minimize its visibility. | file://:0:0:0:0 | (global namespace) | scope | test.c:77:12:77:28 | { ... } | scope | |
2 changes: 2 additions & 0 deletions
2
...essaryexposedidentifierdeclarationshared/UnnecessaryExposedIdentifierDeclarationShared.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// GENERATED FILE - DO NOT MODIFY | ||
import codingstandards.cpp.rules.unnecessaryexposedidentifierdeclarationshared.UnnecessaryExposedIdentifierDeclarationShared |
110 changes: 110 additions & 0 deletions
110
c/common/test/rules/unnecessaryexposedidentifierdeclarationshared/test.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#include <stdbool.h> | ||
extern void f1(int i); | ||
extern int g1; // COMPLIANT | ||
extern int g2; // NON_COMPLIANT; single use of a global variable | ||
bool f2() { return g1 == 1; } | ||
void f3() { | ||
int j = g1; // NON_COMPLIANT | ||
if (f2()) { | ||
int k; // COMPLIANT | ||
f1(j); | ||
f1(k); | ||
} | ||
} | ||
|
||
void f4() { | ||
int j = g1; // COMPLIANT; value of g1 changed between | ||
// definition and use | ||
g1 = 1; | ||
if (f2()) { | ||
f1(j); | ||
} | ||
} | ||
|
||
void f5() { | ||
int j = g1; // COMPLIANT; shouldn't be moved inside loop | ||
while (true) { | ||
int i = g1++; | ||
while (f2()) { | ||
i += j; | ||
} | ||
|
||
if (i % 2) | ||
break; | ||
} | ||
} | ||
|
||
void f6() { | ||
int j = g1; // COMPLIANT; can't moved into smaller scope | ||
#ifdef FOO | ||
if (g1) { | ||
g1 = j + 1; | ||
} | ||
#else | ||
if (g1) { | ||
g1 = j + 2; | ||
} | ||
#endif | ||
} | ||
|
||
void f7() { | ||
int j = g1; // COMPLIANT; potentially stores previous value of | ||
// g1 so moving this would be incorrect. | ||
f1(1); // f1 may change the value of g1 | ||
if (f2()) { | ||
f1(j); | ||
} | ||
} | ||
|
||
void f8() { int i = g2; } | ||
|
||
void f9() { | ||
int i; // NON_COMPLIANT | ||
|
||
if (f2()) { | ||
if (f2()) { | ||
i++; | ||
} else { | ||
i--; | ||
} | ||
} | ||
} | ||
|
||
struct S1 { // NON_COMPLIANT | ||
int i; | ||
}; | ||
|
||
void f10() { struct S1 l1; } | ||
|
||
void f11() { | ||
struct S2 { // COMPLIANT | ||
int i; | ||
} l1; | ||
} | ||
|
||
struct S3 { | ||
int i; | ||
}; | ||
|
||
struct S4 { // NON_COMPLIANT; single use in function f13 | ||
int i; | ||
}; | ||
|
||
void f15() { | ||
int i; // COMPLIANT | ||
|
||
if (i == 0) { | ||
i++; | ||
} | ||
} | ||
|
||
void f17() { | ||
int i; // COMPLIANT | ||
int *ptr; | ||
{ | ||
// Moving the declaration of i into the reduced scope will result in a | ||
// dangling pointer | ||
ptr = &i; | ||
} | ||
*ptr = 1; | ||
} |
38 changes: 38 additions & 0 deletions
38
c/misra/src/rules/RULE-5-2/IdentifiersDeclaredInTheSameScopeNotDistinct.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @id c/misra/identifiers-declared-in-the-same-scope-not-distinct | ||
* @name RULE-5-2: Identifiers declared in the same scope and name space shall be distinct | ||
* @description Using nondistinct identifiers results in undefined behaviour. | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-5-2 | ||
* correctness | ||
* maintainability | ||
* readability | ||
* external/misra/obligation/required | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
import codingstandards.cpp.Identifiers | ||
|
||
from InterestingIdentifiers d, InterestingIdentifiers d2 | ||
where | ||
not isExcluded(d, Declarations5Package::identifiersDeclaredInTheSameScopeNotDistinctQuery()) and | ||
not isExcluded(d2, Declarations5Package::identifiersDeclaredInTheSameScopeNotDistinctQuery()) and | ||
//this rule does not apply if both are external identifiers | ||
//that is covered by RULE-5-3 | ||
not ( | ||
d instanceof ExternalIdentifiers and | ||
d2 instanceof ExternalIdentifiers | ||
) and | ||
d.getNamespace() = d2.getNamespace() and | ||
d.getParentScope() = d2.getParentScope() and | ||
not d = d2 and | ||
d.getLocation().getStartLine() >= d2.getLocation().getStartLine() and | ||
//first 63 chars in the name as per C99 | ||
d.getSignificantNameComparedToMacro() = d2.getSignificantNameComparedToMacro() and | ||
not d.getName() = d2.getName() | ||
select d, | ||
"Identifer " + d.getName() + " is nondistinct in characters at or over 63 limit, compared to $@", | ||
d2, d2.getName() |
38 changes: 38 additions & 0 deletions
38
c/misra/src/rules/RULE-8-5/ExternalObjectOrFunctionNotDeclaredInOneFile.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @id c/misra/external-object-or-function-not-declared-in-one-file | ||
* @name RULE-8-5: An external object or function shall be declared once in one and only one file | ||
* @description Declarations in multiple files can lead to unexpected program behaviour. | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-8-5 | ||
* correctness | ||
* external/misra/obligation/required | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
|
||
from DeclarationEntry de, DeclarationEntry otherDeclaration, string kind | ||
where | ||
not isExcluded(de, Declarations5Package::externalObjectOrFunctionNotDeclaredInOneFileQuery()) and | ||
//this rule applies to non-defining declarations only | ||
not de.isDefinition() and | ||
not otherDeclaration.isDefinition() and | ||
exists(Declaration d | | ||
de.getDeclaration() = d and | ||
otherDeclaration.getDeclaration() = d and | ||
de.getFile() != otherDeclaration.getFile() | ||
) and | ||
( | ||
de.getDeclaration() instanceof Function and kind = "function" | ||
or | ||
de.getDeclaration() instanceof Variable and | ||
not de.getDeclaration() instanceof Parameter and | ||
kind = "variable" | ||
) and | ||
// Apply an ordering based on location to enforce that (de1, de2) = (de2, de1) and we only report (de1, de2). | ||
de.getFile().getAbsolutePath() < otherDeclaration.getFile().getAbsolutePath() | ||
select de, | ||
"The " + kind + " declaration " + de.getName() + | ||
" is declared in multiple files and has an additional $@.", otherDeclaration, "declaration" |
22 changes: 22 additions & 0 deletions
22
c/misra/src/rules/RULE-8-8/MissingStaticSpecifierFunctionRedeclarationC.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @id c/misra/missing-static-specifier-function-redeclaration-c | ||
* @name RULE-8-8: If a function has internal linkage then all re-declarations shall include the static storage class | ||
* @description If a function has internal linkage then all re-declarations shall include the static | ||
* storage class specifier to make the internal linkage explicit. | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-8-8 | ||
* readability | ||
* external/misra/obligation/required | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
import codingstandards.cpp.rules.missingstaticspecifierfunctionredeclarationshared.MissingStaticSpecifierFunctionRedeclarationShared | ||
|
||
class MissingStaticSpecifierFunctionRedeclarationCQuery extends MissingStaticSpecifierFunctionRedeclarationSharedSharedQuery { | ||
MissingStaticSpecifierFunctionRedeclarationCQuery() { | ||
this = Declarations5Package::missingStaticSpecifierFunctionRedeclarationCQuery() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
c/misra/src/rules/RULE-8-8/MissingStaticSpecifierObjectRedeclarationC.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @id c/misra/missing-static-specifier-object-redeclaration-c | ||
* @name RULE-8-8: If an object has internal linkage then all re-declarations shall include the static storage class | ||
* @description If an object has internal linkage then all re-declarations shall include the static | ||
* storage class specifier to make the internal linkage explicit. | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-8-8 | ||
* readability | ||
* external/misra/obligation/required | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
|
||
from VariableDeclarationEntry redeclaration, VariableDeclarationEntry de | ||
where | ||
not isExcluded(redeclaration, | ||
Declarations5Package::missingStaticSpecifierObjectRedeclarationCQuery()) and | ||
//following implies de != redeclaration | ||
de.hasSpecifier("static") and | ||
not redeclaration.hasSpecifier("static") and | ||
de.getDeclaration().isTopLevel() and | ||
redeclaration.getDeclaration() = de.getDeclaration() | ||
select redeclaration, "The redeclaration of $@ with internal linkage misses the static specifier.", | ||
de, de.getName() |
22 changes: 22 additions & 0 deletions
22
c/misra/src/rules/RULE-8-9/UnnecessaryExposedIdentifierDeclarationC.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @id c/misra/unnecessary-exposed-identifier-declaration-c | ||
* @name RULE-8-9: An object should be defined at block scope if its identifier only appears in a single function | ||
* @description An identifier declared to be an object or type shall be defined in a block that | ||
* minimizes its visibility to prevent any accidental use of the identifier. | ||
* @kind problem | ||
* @precision high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-8-9 | ||
* correctness | ||
* external/misra/obligation/advisory | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
import codingstandards.cpp.rules.unnecessaryexposedidentifierdeclarationshared.UnnecessaryExposedIdentifierDeclarationShared | ||
|
||
class UnnecessaryExposedIdentifierDeclarationCQuery extends UnnecessaryExposedIdentifierDeclarationSharedSharedQuery { | ||
UnnecessaryExposedIdentifierDeclarationCQuery() { | ||
this = Declarations5Package::unnecessaryExposedIdentifierDeclarationCQuery() | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-5-2/IdentifiersDeclaredInTheSameScopeNotDistinct.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| test.c:8:5:8:68 | iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyB | Identifer iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyB is nondistinct in characters at or over 63 limit, compared to $@ | test.c:2:5:2:68 | iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA | iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA | |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-5-2/IdentifiersDeclaredInTheSameScopeNotDistinct.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rules/RULE-5-2/IdentifiersDeclaredInTheSameScopeNotDistinct.ql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
extern int | ||
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA; // NON_COMPLIANT | ||
// - | ||
// length | ||
// 64 | ||
|
||
static int | ||
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyB; // NON_COMPLIANT | ||
// - | ||
// length | ||
// 64 | ||
|
||
void f() { | ||
int iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyC; // COMPLIANT | ||
// - | ||
// length | ||
// 64 | ||
// but | ||
// diff | ||
// scope | ||
} | ||
|
||
static int | ||
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjy_C; // COMPLIANT length <63 | ||
static int | ||
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjy_D; // COMPLIANT length <63 | ||
|
||
#define iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA // COMPLIANT | ||
// - | ||
// this | ||
// rule | ||
// does | ||
// not | ||
// consider | ||
// macros | ||
extern int | ||
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA; // COMPLIANT | ||
// - this | ||
// rule | ||
// does | ||
// not | ||
// consider | ||
// when | ||
// both | ||
// identifiers | ||
// are | ||
// external |
2 changes: 2 additions & 0 deletions
2
c/misra/test/rules/RULE-8-5/ExternalObjectOrFunctionNotDeclaredInOneFile.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| test.c:8:12:8:13 | declaration of g3 | The variable declaration g3 is declared in multiple files and has an additional $@. | test1.c:1:12:1:13 | declaration of g3 | declaration | | ||
| test.h:1:12:1:12 | declaration of g | The variable declaration g is declared in multiple files and has an additional $@. | test1.h:1:12:1:12 | declaration of g | declaration | |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-8-5/ExternalObjectOrFunctionNotDeclaredInOneFile.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rules/RULE-8-5/ExternalObjectOrFunctionNotDeclaredInOneFile.ql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "test.h" | ||
#include "test1.h" | ||
|
||
int g = 1; // COMPLIANT | ||
|
||
extern int g1; // COMPLIANT | ||
|
||
extern int g3; // NON_COMPLIANT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern int g; // NON_COMPLIANT | ||
|
||
int g2; // COMPLIANT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extern int g3; // NON_COMPLIANT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern int g; // NON_COMPLIANT | ||
|
||
int g2; // COMPLIANT |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-8-8/MissingStaticSpecifierFunctionRedeclarationC.testref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c/common/test/rules/missingstaticspecifierfunctionredeclarationshared/MissingStaticSpecifierFunctionRedeclarationShared.ql |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-8-8/MissingStaticSpecifierObjectRedeclarationC.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| test.c:2:12:2:12 | declaration of g | The redeclaration of $@ with internal linkage misses the static specifier. | test.c:1:12:1:12 | definition of g | g | |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-8-8/MissingStaticSpecifierObjectRedeclarationC.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rules/RULE-8-8/MissingStaticSpecifierObjectRedeclarationC.ql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
static int g = 0; | ||
extern int g; // NON_COMPLIANT | ||
|
||
static int g1; | ||
static int g1 = 0; // COMPLIANT | ||
|
||
int g2; | ||
int g2 = 0; // COMPLIANT |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-8-9/UnnecessaryExposedIdentifierDeclarationC.testref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c/common/test/rules/unnecessaryexposedidentifierdeclarationshared/UnnecessaryExposedIdentifierDeclarationShared.ql |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.