File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ - ` M7-3-6 ` - ` UsingDeclarationsUsedInHeaderFiles.ql ` :
2
+ - Address FN reported in #400 . Only using-declarations are exempted from class- and function-scope.
Original file line number Diff line number Diff line change @@ -28,5 +28,13 @@ predicate isInClassScope(UsingEntry u) { exists(Class c | u.getEnclosingElement(
28
28
from UsingEntry u
29
29
where
30
30
not isExcluded ( u , BannedSyntaxPackage:: usingDeclarationsUsedInHeaderFilesQuery ( ) ) and
31
- ( isInHeaderFile ( u ) and not isInFunctionScope ( u ) and not isInClassScope ( u ) )
31
+ isInHeaderFile ( u ) and
32
+ (
33
+ u instanceof UsingDeclarationEntry
34
+ implies
35
+ (
36
+ not isInFunctionScope ( u ) and
37
+ not isInClassScope ( u )
38
+ )
39
+ )
32
40
select u , "Using directive or declaration used in a header file " + u .getFile ( ) + "."
Original file line number Diff line number Diff line change 1
1
| test.h:4:1:4:21 | using namespace std | Using directive or declaration used in a header file test.h. |
2
+ | test.h:18:3:18:21 | using namespace std | Using directive or declaration used in a header file test.h. |
Original file line number Diff line number Diff line change @@ -7,11 +7,15 @@ namespace my_namespace {
7
7
int MY_CONST = 0 ;
8
8
};
9
9
10
- int f () {
10
+ void f () {
11
11
12
12
using my_namespace::MY_CONST; // COMPLIANT - function scope
13
13
14
14
int x = MY_CONST;
15
15
}
16
16
17
+ void test_fn_reported_in_400 () {
18
+ using namespace std ; // NON_COMPLIANT - only using declarations are exempted
19
+ // in function scope.
20
+ }
17
21
#endif
You can’t perform that action at this time.
0 commit comments