mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
C++: Add more tests.
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
| hiding.cpp:4:17:4:18 | ii | Local variable 'ii' hides a $@. | hiding.cpp:2:12:2:13 | definition of ii | parameter of the same name |
|
||||
| hiding.cpp:15:15:15:16 | kk | Local variable 'kk' hides a $@. | hiding.cpp:12:25:12:26 | definition of kk | parameter of the same name |
|
||||
| hiding.cpp:28:7:28:7 | a | Local variable 'a' hides a $@. | hiding.cpp:26:21:26:21 | definition of a | parameter of the same name |
|
||||
| hiding.cpp:45:7:45:7 | a | Local variable 'a' hides a $@. | hiding.cpp:39:20:39:20 | definition of a | parameter of the same name |
|
||||
| hiding.cpp:47:7:47:7 | c | Local variable 'c' hides a $@. | hiding.cpp:39:34:39:34 | definition of c | parameter of the same name |
|
||||
| hiding.cpp:64:11:64:11 | i | Local variable 'i' hides a $@. | hiding.cpp:61:20:61:20 | definition of i | parameter of the same name |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
void f(int ii) {
|
||||
if (1) {
|
||||
for(int ii = 1; ii < 10; ii++) {
|
||||
for(int ii = 1; ii < 10; ii++) { // local variable hides global variable
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace foo {
|
||||
void f2(int ii, int kk) {
|
||||
try {
|
||||
for (ii = 0; ii < 3; ii++) {
|
||||
int kk;
|
||||
int kk; // local variable hides global variable
|
||||
}
|
||||
}
|
||||
catch (int ee) {
|
||||
@@ -21,4 +21,45 @@ namespace foo {
|
||||
}
|
||||
}
|
||||
|
||||
void myFunction(int a, int b, int c);
|
||||
|
||||
void myFunction(int a, int b, int _c) {
|
||||
{
|
||||
int a = a; // local variable hides global variable
|
||||
int _b = b;
|
||||
int c = _c;
|
||||
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class MyTemplateClass {
|
||||
public:
|
||||
void myMethod(int a, int b, int c);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void MyTemplateClass<T> :: myMethod(int a, int b, int _c) {
|
||||
{
|
||||
int a = a; // local variable hides global variable
|
||||
int _b = b;
|
||||
int c = _c; // [FALSE POSITIVE]
|
||||
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
MyTemplateClass<int> mtc_i;
|
||||
|
||||
void test() {
|
||||
mtc_i.myMethod(0, 0, 0);
|
||||
}
|
||||
|
||||
#define MYMACRO for (int i = 0; i < 10; i++) {}
|
||||
|
||||
void testMacro(int i) {
|
||||
MYMACRO;
|
||||
|
||||
for (int i = 0; i < 10; i++) {}; // local variable hides global variable
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user