mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
Merge pull request #2622 from MathiasVP/implicit-function-declaration
C++: Add 'implicit function declaration' query
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
| test.c:28:3:28:12 | call to undeclared | Function call implicitly declares 'undeclared'. |
|
||||
| test.c:31:3:31:19 | call to not_yet_declared1 | Function call implicitly declares 'not_yet_declared1'. |
|
||||
| test.c:32:3:32:19 | call to not_yet_declared2 | Function call implicitly declares 'not_yet_declared2'. |
|
||||
| test.c:43:3:43:27 | call to not_declared_defined_with | Function call implicitly declares 'not_declared_defined_with'. |
|
||||
| test.c:54:3:54:21 | call to defined_with_double | Function call implicitly declares 'defined_with_double'. |
|
||||
| test.c:66:3:66:22 | call to defined_with_ptr_ptr | Function call implicitly declares 'defined_with_ptr_ptr'. |
|
||||
| test.c:68:3:68:22 | call to defined_with_ptr_arr | Function call implicitly declares 'defined_with_ptr_arr'. |
|
||||
| test.c:132:3:132:22 | call to implicit_declaration | Function call implicitly declares 'implicit_declaration'. |
|
||||
| test.c:133:3:133:30 | call to implicit_declaration_k_and_r | Function call implicitly declares 'implicit_declaration_k_and_r'. |
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql
|
||||
@@ -25,11 +25,11 @@ void test(int *argv[]) {
|
||||
declared_void(); // GOOD
|
||||
declared_with(1); // GOOD
|
||||
|
||||
undeclared(); // GOOD
|
||||
undeclared(); // BAD (GOOD for everything except cpp/implicit-function-declaration)
|
||||
undeclared(1); // GOOD
|
||||
|
||||
not_yet_declared1(1); // GOOD
|
||||
not_yet_declared2(1); // GOOD
|
||||
not_yet_declared1(1); // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
not_yet_declared2(1); // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
not_yet_declared2(ca); // BAD
|
||||
not_yet_declared2(); // BAD
|
||||
|
||||
@@ -40,7 +40,7 @@ void test(int *argv[]) {
|
||||
declared_empty_defined_with(&x); // BAD
|
||||
declared_empty_defined_with(3, &x); // BAD
|
||||
|
||||
not_declared_defined_with(-1, 0, 2U); // GOOD
|
||||
not_declared_defined_with(-1, 0, 2U); // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
not_declared_defined_with(4LL, 0, 2.5e9f); // BAD
|
||||
|
||||
declared_with_pointers(pv, ca); // GOOD
|
||||
@@ -51,7 +51,7 @@ void test(int *argv[]) {
|
||||
defined_with_float(2.f); // BAD
|
||||
defined_with_float(2.0); // BAD
|
||||
|
||||
defined_with_double(2.f); // GOOD
|
||||
defined_with_double(2.f); // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
defined_with_double('c'); // BAD
|
||||
|
||||
defined_with_long_long('c'); // BAD
|
||||
@@ -63,9 +63,9 @@ void test(int *argv[]) {
|
||||
k_and_r_func(2.5, &s); // GOOD
|
||||
|
||||
int (*parameterName)[2];
|
||||
defined_with_ptr_ptr(parameterName); // GOOD
|
||||
defined_with_ptr_ptr(parameterName); // // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
defined_with_ptr_ptr(argv); // GOOD
|
||||
defined_with_ptr_arr(parameterName); // GOOD
|
||||
defined_with_ptr_arr(parameterName); // // BAD (GOOD for everything except for cpp/implicit-function-declaration)
|
||||
defined_with_ptr_arr(argv); // GOOD
|
||||
|
||||
declared_and_defined_empty(); // GOOD
|
||||
@@ -124,3 +124,15 @@ int call_k_and_r(int i) {
|
||||
int will_be_k_and_r(val)
|
||||
int val;
|
||||
{ return val + 1; }
|
||||
|
||||
extern int extern_definition(double, double*);
|
||||
|
||||
void test_implicit_function_declaration(int x, double d) {
|
||||
int y;
|
||||
implicit_declaration(1, 2); // BAD
|
||||
implicit_declaration_k_and_r(1, 2); // BAD
|
||||
|
||||
implicit_declaration(1, 2); // GOOD (no longer an implicit declaration)
|
||||
|
||||
y = extern_definition(3.0f, &d); // GOOD
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
void implicit_declaration(int x) {}
|
||||
|
||||
int implicit_declaration_k_and_r(x) int x;
|
||||
{
|
||||
return x;
|
||||
}
|
||||
Reference in New Issue
Block a user