Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5150bf3

Browse files
committed
C++: Add another test case inspired by CPP-331.
1 parent 1483306 commit 5150bf3

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

cpp/ql/test/query-tests/Best Practices/Hiding/DeclarationHidesParameter/DeclarationHidesParameter.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
| 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 |
55
| 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 |
66
| 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 |
7+
| hiding.cpp:78:7:78:10 | arg1 | Local variable 'arg1' hides a $@. | hiding.cpp:74:28:74:31 | definition of arg1 | parameter of the same name |
8+
| hiding.cpp:79:5:79:8 | arg2 | Local variable 'arg2' hides a $@. | hiding.cpp:74:36:74:39 | definition of arg2 | parameter of the same name |

cpp/ql/test/query-tests/Best Practices/Hiding/DeclarationHidesParameter/hiding.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,19 @@ void testMacro(int i) {
6363

6464
for (int i = 0; i < 10; i++) {}; // local variable hides global variable
6565
}
66+
67+
#include "hiding.h"
68+
69+
void myClass::myCaller(void) {
70+
this->myMethod(5, 6);
71+
}
72+
73+
template <typename T>
74+
void myClass::myMethod(int arg1, T arg2) {
75+
{
76+
int protoArg1;
77+
T protoArg2;
78+
int arg1; // local variable hides global variable
79+
T arg2; // local variable hides global variable
80+
}
81+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
class myClass {
3+
public:
4+
template <typename T>
5+
void myMethod(int protoArg1, T protoArg2);
6+
void myCaller(void);
7+
};

0 commit comments

Comments
 (0)