C++: Merge two tests of UnusedStaticFunctions from the library-tests into the existing test in query-test.

This commit is contained in:
Geoffrey White
2020-01-23 10:59:54 +00:00
parent f40a37cae2
commit 0c4eabca98
7 changed files with 6 additions and 8 deletions

View File

@@ -1,3 +1,9 @@
| unused_functions.c:16:13:16:27 | unused_function | Static function unused_function is unreachable | unused_functions.c:16:13:16:27 | unused_function | unused_function |
| unused_functions.c:20:13:20:28 | unused_function2 | Static function unused_function2 is unreachable ($@ must be removed at the same time) | unused_functions.c:24:13:24:28 | unused_function3 | unused_function3 |
| unused_functions.c:24:13:24:28 | unused_function3 | Static function unused_function3 is unreachable | unused_functions.c:24:13:24:28 | unused_function3 | unused_function3 |
| unused_functions.c:63:13:63:14 | h4 | Static function h4 is unreachable | unused_functions.c:63:13:63:14 | h4 | h4 |
| unused_mut.c:5:13:5:31 | mut_unused_function | Static function mut_unused_function is unreachable ($@ must be removed at the same time) | unused_mut.c:9:13:9:32 | mut_unused_function2 | mut_unused_function2 |
| unused_mut.c:9:13:9:32 | mut_unused_function2 | Static function mut_unused_function2 is unreachable ($@ must be removed at the same time) | unused_mut.c:5:13:5:31 | mut_unused_function | mut_unused_function |
| unused_static_functions.cpp:19:13:19:14 | f2 | Static function f2 is unreachable | unused_static_functions.cpp:19:13:19:14 | f2 | f2 |
| unused_static_functions.cpp:33:13:33:14 | f5 | Static function f5 is unreachable ($@ must be removed at the same time) | unused_static_functions.cpp:34:13:34:14 | f6 | f6 |
| unused_static_functions.cpp:34:13:34:14 | f6 | Static function f6 is unreachable ($@ must be removed at the same time) | unused_static_functions.cpp:33:13:33:14 | f5 | f5 |

View File

@@ -0,0 +1,64 @@
// semmle-extractor-options: -fblocks
#ifdef COMPILABLE_TEST
#include <stdio.h>
#else
void printf(char *str);
#endif
static void used_function(void) {
printf("Gets run\n");
}
static void used_function2(void) {
printf("Gets run 2\n");
}
static void unused_function(void) {
printf("Doesn't get run\n");
}
static void unused_function2(void) {
printf("Doesn't get run 2\n");
}
static void unused_function3(void) {
printf("Doesn't get run 3\n");
unused_function2();
}
static void __attribute__ ((constructor (300))) f300(void) {
printf("Constructor 300 running\n");
}
static void __attribute__ ((constructor)) f(void) {
printf("Constructor running\n");
}
int main(void) {
printf("Main running\n");
used_function();
used_function2();
int (^four)(void) = ^{ return 4; };
return 0;
}
static void __attribute__ ((destructor)) g(void) {
printf("Destructor running\n");
}
static void __attribute__ ((destructor (300))) g300(void) {
printf("Destructor 300 running\n");
}
static void h2(void) {
}
static void __attribute__ ((used)) h1(void) {
h2();
}
static void __attribute__ ((unused)) h3(void) {
}
static void h4(void) {
}

View File

@@ -0,0 +1,19 @@
static void mut_unused_function(void);
static void mut_unused_function2(void);
static void mut_unused_function(void) {
mut_unused_function2();
}
static void mut_unused_function2(void) {
mut_unused_function();
}
static void f(void) { }
static void g(void) { f(); }
static void h(void) { void (*fun)(void) = g; }
static void i(void) { h(); }
static void j(void) { i(); }
void k(void) { j(); }