diff options
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/Waddress-weak.c | 2 | ||||
| -rw-r--r-- | validation/Waddress.c | 4 | ||||
| -rw-r--r-- | validation/bug-bad-type.c | 18 | ||||
| -rw-r--r-- | validation/empty-expr.c | 26 | ||||
| -rw-r--r-- | validation/linear/bitfield-expand-deref.c | 27 | ||||
| -rw-r--r-- | validation/linear/degen-function.c | 13 | ||||
| -rw-r--r-- | validation/optim/cse-fcmp.c | 19 |
7 files changed, 109 insertions, 0 deletions
diff --git a/validation/Waddress-weak.c b/validation/Waddress-weak.c index 1fe8d33c..ad2cb13a 100644 --- a/validation/Waddress-weak.c +++ b/validation/Waddress-weak.c @@ -9,11 +9,13 @@ int test_addr_weak_fun(void) if ( &arr) return 1; if ( fun) return 1; if ( &fun) return 1; + if ( *fun) return 1; if (!&var) return 0; if (! arr) return 0; if (!&arr) return 0; if (! fun) return 0; if (!&fun) return 0; + if (!*fun) return 0; return -1; } diff --git a/validation/Waddress.c b/validation/Waddress.c index 10556c3a..441cdb1c 100644 --- a/validation/Waddress.c +++ b/validation/Waddress.c @@ -15,6 +15,7 @@ lab: if (&arr) return 1; if (fun) return 1; if (&fun) return 1; + if (*fun) return 1; if (&var) return 1; if (&arg) return 1; if (&&lab) return 1; @@ -35,6 +36,7 @@ lab: if (!&arr) return 0; if (!fun) return 0; if (!&fun) return 0; + if (!*fun) return 0; if (!&var) return 0; if (!&arg) return 0; if (!&&lab) return 0; @@ -62,6 +64,8 @@ lab: if (0 == fun) return 0; if (&fun == 0) return 0; if (0 == &fun) return 0; + if (*fun == 0) return 0; + if (0 == *fun) return 0; if (&var == 0) return 0; if (0 == &var) return 0; if (&arg == 0) return 0; diff --git a/validation/bug-bad-type.c b/validation/bug-bad-type.c new file mode 100644 index 00000000..0e00efef --- /dev/null +++ b/validation/bug-bad-type.c @@ -0,0 +1,18 @@ +struct s { + int i; +}; + +long a; +void foo(void) +{ + (struct s) { .i = (foo - a), }; +} + +/* + * check-name: bug-bad-type + * + * check-error-start +bug-bad-type.c:5:6: warning: symbol 'a' was not declared. Should it be static? +bug-bad-type.c:8:32: error: arithmetics on pointers to functions + * check-error-end + */ diff --git a/validation/empty-expr.c b/validation/empty-expr.c new file mode 100644 index 00000000..61decf73 --- /dev/null +++ b/validation/empty-expr.c @@ -0,0 +1,26 @@ +static int foo(void) +{ + switch () { + case 0: + return 0; + default: + return 1; + } +} + +static int bar(void) +{ + if () + return 0; + else + return 1; +} + +/* + * check-name: empty expression + * + * check-error-start +empty-expr.c:3:17: error: an expression is expected before ')' +empty-expr.c:13:13: error: an expression is expected before ')' + * check-error-end + */ diff --git a/validation/linear/bitfield-expand-deref.c b/validation/linear/bitfield-expand-deref.c new file mode 100644 index 00000000..7748725f --- /dev/null +++ b/validation/linear/bitfield-expand-deref.c @@ -0,0 +1,27 @@ +struct s { + int a:8; + int b:8; +}; + +int foo(void) +{ + struct s x = { .a = 12, .b = 34, }; + + return x.b; +} + +int bar(int a) +{ + struct s x = { .a = 12, .b = a, }; + + return x.b; +} + +/* + * check-name: bitfield expand deref + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: ret\..*\$12 + * check-output-contains: ret\..*\$34 + */ diff --git a/validation/linear/degen-function.c b/validation/linear/degen-function.c index 6dd3123b..4fb2d564 100644 --- a/validation/linear/degen-function.c +++ b/validation/linear/degen-function.c @@ -4,6 +4,7 @@ typedef int (*fun_t)(int); fun_t fa(void) { return &fun; } fun_t f0(void) { return fun; } +fun_t f1(void) { return *fun; } /* * check-name: degen-function @@ -34,5 +35,17 @@ f0: ret.64 %r3 +f1: +.L4: + <entry-point> + symaddr.64 %r5 <- fun + phisrc.64 %phi3(return) <- %r5 + br .L5 + +.L5: + phi.64 %r6 <- %phi3(return) + ret.64 %r5 + + * check-output-end */ diff --git a/validation/optim/cse-fcmp.c b/validation/optim/cse-fcmp.c new file mode 100644 index 00000000..f2a73f57 --- /dev/null +++ b/validation/optim/cse-fcmp.c @@ -0,0 +1,19 @@ +extern void fun(void); + +int foo(double a, double b) +{ + if (a < b) + fun(); + if (a < b) + return 1; + + return 0; +} + +/* + * check-name: cse-fcmp + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern(1): fcmp + */ |
