diff options
Diffstat (limited to 'gcc-4.4.0/gcc/testsuite/g++.dg/warn')
7 files changed, 103 insertions, 17 deletions
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Warray-bounds.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Warray-bounds.C index 0385516ab..06b0a39ec 100644 --- a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Warray-bounds.C +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Warray-bounds.C @@ -26,10 +26,10 @@ int* f(void) { a[ 9] = 0; a[10] = 0; /* { dg-warning "array subscript" } */ a[11] = 0; /* { dg-warning "array subscript" } */ - a[2 * n() - 11] = 0; /* { dg-warning "array subscript" } */ - a[2 * n() - 10] = 0; - a[2 * n() - 1] = 0; - a[2 * n() - 0] = 0; /* { dg-warning "array subscript" } */ + a[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */ + a[2 * n() - 10] = 1; + a[2 * n() - 1] = 1; + a[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */ b[-1] = 0; /* { dg-warning "array subscript" } */ b[ 0] = 0; @@ -37,10 +37,10 @@ int* f(void) { b[ 9] = 0; b[10] = 0; /* { dg-warning "array subscript" } */ b[11] = 0; /* { dg-warning "array subscript" } */ - b[2 * n() - 11] = 0; /* { dg-warning "array subscript" } */ - b[2 * n() - 10] = 0; - b[2 * n() - 1] = 0; - b[2 * n() - 0] = 0; /* { dg-warning "array subscript" } */ + b[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */ + b[2 * n() - 10] = 1; + b[2 * n() - 1] = 1; + b[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */ c.c[-1] = 0; /* { dg-warning "array subscript" } */ c.c[ 0] = 0; @@ -48,10 +48,10 @@ int* f(void) { c.c[ 9] = 0; c.c[10] = 0; /* { dg-warning "array subscript" } */ c.c[11] = 0; /* { dg-warning "array subscript" } */ - c.c[2 * n() - 11] = 0; /* { dg-warning "array subscript" } */ - c.c[2 * n() - 10] = 0; - c.c[2 * n() - 1] = 0; - c.c[2 * n() - 0] = 0; /* { dg-warning "array subscript" } */ + c.c[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */ + c.c[2 * n() - 10] = 1; + c.c[2 * n() - 1] = 1; + c.c[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */ g(&a[8]); g(&a[9]); @@ -88,4 +88,3 @@ int* f(void) { return a; } - diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wicf.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wicf.C new file mode 100644 index 000000000..98fb21571 --- /dev/null +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wicf.C @@ -0,0 +1,31 @@ +// Test -Wicf to warn about function pointers used in comparisons. +// Origin: Sriraman Tallam <tmsriram@google.com> + +// { dg-do compile} +// { dg-options "-Wicf" } + +struct A +{ + int foo (int); + int bar (int); +}; + +extern int foo (int); +extern int baz (int); + +int (*funcptr) (int); +int (A::*Aptr) (int); +void +bar (int a) +{ + funcptr = baz; + Aptr = &A::foo; + if (foo == funcptr) // { dg-warning "Function pointer used" "correct warning" } + foo (10); + if (funcptr == baz) // { dg-warning "Function pointer used" "correct warning" } + foo (10); + if (&A::foo == &A::bar) // { dg-warning "Method pointer used" "correct warning" } + foo (10); + if (Aptr == &A::foo) // { dg-warning "Method pointer used" "correct warning" } + foo (10); +} diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C new file mode 100644 index 000000000..497e3b9eb --- /dev/null +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C @@ -0,0 +1,13 @@ +/* PR c++/40749 */ +/* { dg-do "compile" } */ +/* { dg-options "-Wreturn-type" } */ + +struct A {}; +const A a() {} /* { dg-warning "no return statement" } */ +const A& b() {} /* { dg-warning "no return statement" } */ + +const int c() {} /* { dg-warning "no return statement" } */ + +template<class T> +const int foo(T t) {} /* { dg-warning "no return statement" } */ +int d = foo<int>(0), e = foo<int>(1); diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C new file mode 100644 index 000000000..3d2543fb1 --- /dev/null +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C @@ -0,0 +1,22 @@ +// PR middle-end/39666 +// { dg-do compile } +// { dg-options "-O2 -Wuninitialized" } + +int +foo (int i) +{ + int j; + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 1 ... __INT_MAX__: + j = 4; + break; + } + return j; +} diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C new file mode 100644 index 000000000..ff17acd6a --- /dev/null +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C @@ -0,0 +1,22 @@ +// PR middle-end/39666 +// { dg-do compile } +// { dg-options "-O2 -Wuninitialized" } + +int +foo (int i) +{ + int j; + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 2 ... __INT_MAX__: + j = 4; + break; + } + return j; +} // { dg-warning "may be used uninitialized" } diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/pragma-system_header3.h b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/pragma-system_header3.h index e16f38f8a..1e96234ad 100644 --- a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/pragma-system_header3.h +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/pragma-system_header3.h @@ -3,5 +3,5 @@ static inline int f() { int i; - return i; + return i + 1; } diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/unit-1.C b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/unit-1.C index 1bfe75b2f..432ba1d7e 100644 --- a/gcc-4.4.0/gcc/testsuite/g++.dg/warn/unit-1.C +++ b/gcc-4.4.0/gcc/testsuite/g++.dg/warn/unit-1.C @@ -4,7 +4,6 @@ struct a { int mode; }; int sys_msgctl (void) { - struct a setbuf; /* { dg-warning "'setbuf\.a::mode' is used" } */ + struct a setbuf; return setbuf.mode; -} - +} /* { dg-warning "'setbuf\.a::mode' is used" } */ |