Skip to content

Explicitly specify no-argument function pointers in tests #1724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/incremental/11-restart/11-paper-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

int (*fp)() = NULL;
int (*fp)(void) = NULL;

int bad() {
return -1;
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/00-sanity/15-unused_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ void f() {
glob++; // NOWARN!
}

void (*fptr) = f;
void (*fptr)(void) = f;

int g(void (*ptr)()) {
int g(void (*ptr)(void)) {
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/00-sanity/38-evalfunvar-dead.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdlib.h>

int main() {
int (*fp)() = &rand;
int (*fp)(void) = &rand;
abort();
fp(); // NOWARN (No suitable function to call)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/01-cpa/06-pointers.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int fun_5b() { return 5; }
int main () {
int i,j,k1,k2,k3;
int *p, **pp;
int (*fp)(); //pointer to function
int (*fp)(void); //pointer to function

// reading through pointer
i = 5;
Expand Down
6 changes: 3 additions & 3 deletions tests/regression/01-cpa/09-arrays.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ int main () {

int a[] = {2,2,2};
int b[2], c[3];
int (*f[2])() = {fun_5, fun_6};
int (*g[2])() = {fun_5, fun_5b};
int (*fp)();
int (*f[2])(void) = {fun_5, fun_6};
int (*g[2])(void) = {fun_5, fun_5b};
int (*fp)(void);
int *ip;
int (*iap)[];

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/01-cpa/46-funptr_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void fun2() {
int main() {
int x = __VERIFIER_nondet_int();

void (*fp)();
void (*fp)(void);

if (x) {
pthread_mutex_lock(&mutex);
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/02-base/46-spawn-global-funptrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ void bar() {
__goblint_check(1); // assert reachable
}

void (*funs[2])() = {
void (*funs[2])(void) = {
&foo,
&bar
};

extern void magic1();
extern void magic2(void (*funs[])());
extern void magic2(void (*funs[])(void));

int main() {
magic1(); // invalidate funs a bit
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/03-practical/06-callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void callme(void) {
x = 5;
}

void callfun(void (*fun)()) {
void callfun(void (*fun)(void)) {
fun();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/19-call_by_ptr_rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern int __VERIFIER_nondet_int();

#include<pthread.h>

void foo(int (*callback)()) {
void foo(int (*callback)(void)) {
for (int i = 0; i < 10; i++) {
if (__VERIFIER_nondet_int())
callback();
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/21-sound_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int global;
void bad() { global++; } // RACE!
void good() { printf("Hello!"); }

void (*f)() = good;
void (*f)(void) = good;

void *t_fun(void *arg) {
f(); // RACE!
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/04-mutex/27-base_rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ void good() {
pthread_mutex_unlock(&gm);
}

void (*f)() = good;
void (*f)(void) = good;
pthread_mutex_t fm = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
void (*g)();
void (*g)(void);

pthread_mutex_lock(&fm);
g = f; // NORACE
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/04-mutex/28-base_nr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ void good() {
pthread_mutex_unlock(&gm);
}

void (*f)() = good;
void (*f)(void) = good;
pthread_mutex_t fm = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
void (*g)();
void (*g)(void);

pthread_mutex_lock(&fm);
g = f; // NORACE
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/29-funstruct_rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pthread_mutex_t B_mutex = PTHREAD_MUTEX_INITIALIZER;

struct ops {
int (*f)(int);
void (*g)();
void (*g)(void);
};

extern void register_dev(struct ops *);
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/30-funstruct_nr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pthread_mutex_t B_mutex = PTHREAD_MUTEX_INITIALIZER;

struct ops {
int (*f)(int);
void (*g)();
void (*g)(void);
};

extern void register_dev(struct ops *);
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/50-funptr_rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
int f1() { return 4; }
int f2() { return 5; }

int (*fp)() = f1;
int (*fp)(void) = f1;

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/04-mutex/56-extern_call_by_ptr_rc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include<pthread.h>

extern void foo(int (*callback)());
extern void foo(int (*callback)(void));


int glob;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/13-privatized/95-mm-calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include<stdlib.h>
#include<stdio.h>
struct a {
void (*b)();
void (*b)(void);
};

int g = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ int main () {

int a[] = {2,2,2};
int b[2], c[3];
int (*f[2])() = {fun_5, fun_6};
int (*g[2])() = {fun_5, fun_5b};
int (*fp)();
int (*f[2])(void) = {fun_5, fun_6};
int (*g[2])(void) = {fun_5, fun_5b};
int (*fp)(void);
int *ip;
int (*iap)[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ int main () {

int a[] = {2,2,2};
int b[2], c[3];
int (*f[2])() = {fun_5, fun_6};
int (*g[2])() = {fun_5, fun_5b};
int (*fp)();
int (*f[2])(void) = {fun_5, fun_6};
int (*g[2])(void) = {fun_5, fun_5b};
int (*fp)(void);
int *ip;
int (*iap)[];

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/28-race_reach/19-callback_racing.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern int __VERIFIER_nondet_int();
#include<pthread.h>
#include "racemacros.h"

void foo(int (*callback)()) {
void foo(int (*callback)(void)) {
for (int i = 0; i < 10; i++) {
if (__VERIFIER_nondet_int())
callback();
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/28-race_reach/20-callback_racefree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern int __VERIFIER_nondet_int();
#include<pthread.h>
#include "racemacros.h"

void foo(int (*callback)()) {
void foo(int (*callback)(void)) {
for (int i = 0; i < 10; i++) {
if (__VERIFIER_nondet_int())
callback();
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/28-race_reach/27-funptr_racing.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ void good() {
pthread_mutex_unlock(&gm);
}

void (*f)() = good;
void (*f)(void) = good;
pthread_mutex_t fm = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
void (*g)();
void (*g)(void);

pthread_mutex_lock(&fm);
g = f;
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/28-race_reach/28-funptr_racefree.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ void good() {
pthread_mutex_unlock(&gm);
}

void (*f)() = good;
void (*f)(void) = good;
pthread_mutex_t fm = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
void (*g)();
void (*g)(void);

pthread_mutex_lock(&fm);
g = f;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/28-race_reach/95-deref-fun.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// PARAM: --enable ana.sv-comp.enabled --set ana.specification "CHECK( init(main()), LTL(G ! call(reach_error())) )"
#include<pthread.h>
// NOCRASH
void foo(int (*callback)()) {
void foo(int (*callback)(void)) {
}
Comment on lines 3 to 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was a nocrash test, I'm not sure if the modified test still meets the intention.


int bar() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ int main () {

int a[] = {2,2,2};
int b[2], c[3];
int (*f[2])() = {fun_5, fun_6};
int (*g[2])() = {fun_5, fun_5b};
int (*fp)();
int (*f[2])(void) = {fun_5, fun_6};
int (*g[2])(void) = {fun_5, fun_5b};
int (*fp)(void);
int *ip;
int (*iap)[];

Expand Down
2 changes: 1 addition & 1 deletion tests/sv-comp/cfg/free_spawn_ub_true-unreach-call.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void foo()

int main()
{
void (*p)() = &foo;
void (*p)(void) = &foo;
free(p); // TODO: free shouldn't spawn
return 0;
}
32 changes: 16 additions & 16 deletions tests/sv-comp/cfg/free_spawn_ub_true-unreach-call.expected
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
┌───────────────────────────────────
_
└───────────────────────────────────
┌─────────────────────┐
_
└─────────────────────┘
│ Entry main
┌───────────────────────────────────
_
└───────────────────────────────────
┌─────────────────────┐
_
└─────────────────────┘
│ Assign 'p = (void (*)())(& foo)'
│ Assign 'p = & foo'
┌───────────────────────────────────
_
└───────────────────────────────────
┌─────────────────────┐
_
└─────────────────────┘
│ Proc 'free(p)'
┌───────────────────────────────────
_
└───────────────────────────────────
┌─────────────────────┐
_
└─────────────────────┘
│ Ret (Some 0, main)
┌───────────────────────────────────
_
└───────────────────────────────────
┌─────────────────────┐
_
└─────────────────────┘
Loading