From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/g++.dg/warn/Wunused-var-5.C | 227 ++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-5.C (limited to 'gcc/testsuite/g++.dg/warn/Wunused-var-5.C') diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-5.C b/gcc/testsuite/g++.dg/warn/Wunused-var-5.C new file mode 100644 index 000000000..7fcaa955c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-5.C @@ -0,0 +1,227 @@ +// { dg-do compile } +// { dg-options "-Wunused" } + +template +void +f1 (void) +{ + int a; // { dg-warning "set but not used" } + int b; + int c; + c = 1; + a = b = c; +} + +template +void +f2 (int x) +{ + int a; // { dg-warning "set but not used" } + int b; + int c; // { dg-warning "set but not used" } + c = (a = x, b = x); +} + +template +int +f3 (int x) +{ + int a; + return a = x; +} + +template +int +f4 (int x) +{ + int a; + a = x; + return a; +} + +template +void +f5 (int x) +{ + int a[2]; // { dg-warning "set but not used" } + int b; + int *c, d[2]; + c = d; + b = x; + a[b] = 1; + c[b] = 1; +} + +template +int +f6 (int x) +{ + int a[2]; + int b; + b = x; + a[b] = 1; + return a[b]; +} + +template +void +f7 (int x, int *p) +{ + int *a[2]; + a[x] = p; + a[x][x] = x; +} + +struct S { int i; }; + +template +void +f8 (void) +{ + struct S s; // { dg-warning "set but not used" } + s.i = 6; +} + +template +int +f9 (void) +{ + struct S s; + s.i = 6; + return s.i; +} + +template +struct S +f10 (void) +{ + struct S s; + s.i = 6; + return s; +} + +extern int foo11 (int *); + +template +void +f11 (void) +{ + int a[2]; + foo11 (a); +} + +template +void +f12 (void) +{ + int a; + a = 1; + a; // { dg-warning "statement has no effect" } +} + +template +void +f13 (void (*x) (void)) +{ + void (*a) (void); + a = x; + a (); +} + +template +void +f14 (void (*x) (void)) +{ + void (*a) (void); // { dg-warning "set but not used" } + a = x; +} + +extern void foo15 (int *); + +template +void +f15 (void) +{ + int a[10]; + int *b = a + 2; + foo15 (b); +} + +extern void foo16 (int **); + +template +void +f16 (void) +{ + int a[10]; + int *b[] = { a, a + 2 }; + foo16 (b); +} + +template +void +f17 (int x) +{ + long a; // { dg-warning "set but not used" } + int b; + a = b = x; +} + +template +void +f18 (int x) +{ + int a; // { dg-warning "set but not used" } + int b; + a = (char) (b = x); +} + +template +int +f19 (int x, int y, int z) +{ + int a; + int b; + a = x; + b = y; + return z ? a : b; +} + +template +int * +f20 (int x) +{ + static int a[] = { 3, 4, 5, 6 }; + static int b[] = { 4, 5, 6, 7 }; + static int c[] = { 5, 6, 7, 8 }; // { dg-warning "set but not used" } + c[1] = 1; + return x ? a : b; +} + +S s; + +void +test () +{ + int i = 0; + f1<0> (); + f2<0> (0); + (void) f3<0> (0); + (void) f4<0> (0); + f5<0> (0); + (void) f6<0> (0); + f7<0> (0, &i); + f8<0> (); + (void) f9<0> (); + s = f10<0> (); + f11<0> (); + f12<0> (); + f13<0> (f1<0>); + f14<0> (f1<0>); + f15<0> (); + f16<0> (); + f17<0> (0); + f18<0> (0); + (void) f19<0> (0, 0, 0); + (void) f20<0> (0); +} -- cgit v1.2.3