diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-19 22:43:06 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-17 10:04:37 +0100 |
| commit | 0f1700e896ed0111fa7e248c307c620fd8506000 (patch) | |
| tree | 76d30477e65bc8bf45e530ba6c80109ab8f1adb0 /validation/backend | |
| parent | 880cd2465e6f2badda7c7e9e81d1d4cca7a35833 (diff) | |
| download | sparse-dev-0f1700e896ed0111fa7e248c307c620fd8506000.tar.gz | |
llvm: fix mutating function pointer
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/backend')
| -rw-r--r-- | validation/backend/function-ptr-xtype.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/validation/backend/function-ptr-xtype.c b/validation/backend/function-ptr-xtype.c new file mode 100644 index 00000000..9cdfab05 --- /dev/null +++ b/validation/backend/function-ptr-xtype.c @@ -0,0 +1,37 @@ +typedef int (*binop_t)(int, int); +typedef int (*unop_t)(int); +typedef int (*idef_t)(void); +typedef long (*ldef_t)(void); +typedef void (*use_t)(int); + +// We want to 'fn' have several different types. +// The goal is for the ->priv member to be used +// with a type different from what it was first stored. + +int foo(void *fn, int arg1, int arg2); +int foo(void *fn, int arg1, int arg2) +{ + int res = 0; + + res += ((binop_t)fn)(arg1, arg2); + res += ((unop_t)fn)(arg1); + res += ((ldef_t)fn)(); + res += ((idef_t)fn)(); + ((use_t)fn)(res); + return res; +} + +int bar(int (*fn)(int), int arg1, int arg2); +int bar(int (*fn)(int), int arg1, int arg2) +{ + int res = 0; + + res += ((binop_t)fn)(arg1, arg2); + res += fn(arg1); + return res; +} + +/* + * check-name: mutate function pointer's type + * check-command: ./sparsec -c $file -o tmp.o + */ |
