aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.0/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.0/gcc/testsuite/g++.dg')
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/debug/dwarf2/icf.C48
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C22
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C26
-rwxr-xr-xgcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C14
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/parse/cond5.C10
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_common.h7
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C31
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-44.C58
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/torture/pr40389.C84
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/tree-prof/dom-invalid.C (renamed from gcc-4.4.0/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C)5
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_a.C63
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_b.C63
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_a.C62
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_b.C62
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_a.cc21
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.cc21
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_c.cc23
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop_1.cc21
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/Warray-bounds.C25
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wicf.C31
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C13
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C22
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C22
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/pragma-system_header3.h2
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/warn/unit-1.C5
25 files changed, 741 insertions, 20 deletions
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/debug/dwarf2/icf.C b/gcc-4.4.0/gcc/testsuite/g++.dg/debug/dwarf2/icf.C
new file mode 100644
index 000000000..86f18d4f8
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/debug/dwarf2/icf.C
@@ -0,0 +1,48 @@
+// Test support for ICF debugging.
+// { dg-do compile }
+// { dg-options "-O0 -gdwarf-2 -fenable-icf-debug -dA" }
+
+class A
+{
+ public:
+ A();
+ virtual void work();
+ virtual int p();
+ private:
+ int i;
+};
+
+class B
+{
+ public:
+ B();
+ ~B();
+ void work(const A* a);
+ private:
+ int j;
+};
+
+int
+test1(A* a)
+{
+ a->work();
+}
+
+int
+test2(A* a)
+{
+ if (a->p())
+ {
+ B b;
+ b.work(a);
+ }
+}
+
+// Verify that we get .debug_dcall and .debug_vcall tables generated,
+// that we see the proper number of points of call, and that we see
+// entries for both virtual calls.
+// { dg-final { scan-assembler "\\.section.*\.debug_dcall" } }
+// { dg-final { scan-assembler "\\.section.*\.debug_vcall" } }
+// { dg-final { scan-assembler-times "Point of call" 6 } }
+// { dg-final { scan-assembler "0x0.*Vtable slot" } }
+// { dg-final { scan-assembler "0x1.*Vtable slot" } }
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C
new file mode 100644
index 000000000..87f263c9c
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-options "-fno-strict-enum-precision" } */
+
+enum zero_one { zero = 0, one = 1 };
+
+int* allocate_bool(zero_one e) {
+ int* v = 0;
+ switch (e) {
+ case zero: v = new int(0);
+ case one: v = new int(1);
+ }
+ return v;
+}
+
+int main() {
+ if (allocate_bool(static_cast<zero_one>(999))) {
+ /* Error: should not have matched any case label. */
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C
new file mode 100644
index 000000000..5b6af1743
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-strict-enum-precision" } */
+
+enum X {
+ X1,
+ X2
+};
+
+int foo (enum X x) {
+ switch (x) {
+ case X1:
+ return 0;
+ case X2:
+ return 1;
+ }
+ return x;
+}
+
+int main(int argc, char *argv[]) {
+ int n = argc + 999;
+ if (n == foo(static_cast<X>(n))) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C
new file mode 100755
index 000000000..c3802a813
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-strict-enum-precision" } */
+
+enum X {
+ X1,
+ X2
+};
+
+int main(int argc, char *argv[]) {
+ X x = static_cast<X>(argc + 999);
+ if (x == X1) return 1;
+ if (x == X2) return 1;
+ return 0;
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/parse/cond5.C b/gcc-4.4.0/gcc/testsuite/g++.dg/parse/cond5.C
new file mode 100644
index 000000000..7ed9fbe89
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/parse/cond5.C
@@ -0,0 +1,10 @@
+// PR c++/40566
+
+void
+f (int x, int y)
+{
+ int c = x ? 23 : throw "bla";
+ short d = y ? throw "bla" : 23;
+ char e = x ? 23 : throw "bla";
+ long f = x ? 23 : throw "bla";
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_common.h b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_common.h
index 5344fed0e..192c84e84 100644
--- a/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_common.h
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_common.h
@@ -74,4 +74,11 @@ class SCOPED_LOCKABLE ReaderMutexLock {
~ReaderMutexLock() UNLOCK_FUNCTION();
};
+class SCOPED_LOCKABLE ReleasableMutexLock {
+ public:
+ explicit ReleasableMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+ ~ReleasableMutexLock() UNLOCK_FUNCTION();
+ void Release() UNLOCK_FUNCTION();
+};
+
#endif // THREAD_ANNOT_COMMON_H
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C
new file mode 100644
index 000000000..36fcb1bc4
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C
@@ -0,0 +1,31 @@
+// Test lock canonicalization when populating the initial lock sets of a
+// function. It locks are properly canonicalized, the analysis should not
+// complained about a_ in function FooBar::GetA() is not protected.
+// This is a good test case. (i.e. There should be no warning emitted by the
+// compiler.)
+// { dg-do compile }
+// { dg-options "-Wthread-safety -O" }
+
+#include "thread_annot_common.h"
+
+class Foo {
+ public:
+ Mutex *mu_;
+};
+
+class FooBar {
+ public:
+ Foo *foo_;
+ int GetA() EXCLUSIVE_LOCKS_REQUIRED(foo_->mu_) { return a_; }
+ int a_ GUARDED_BY(foo_->mu_);
+};
+
+FooBar *fb;
+
+main()
+{
+ int x;
+ fb->foo_->mu_->Lock();
+ x = fb->GetA();
+ fb->foo_->mu_->Unlock();
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-44.C b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-44.C
new file mode 100644
index 000000000..4b1618818
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-44.C
@@ -0,0 +1,58 @@
+// Test the support for releasable scoped lock (e.g std::unique_lock).
+// This is a good test case. (i.e. There should be no warning emitted by the
+// compiler.)
+// { dg-do compile }
+// { dg-options "-Wthread-safety -O" }
+
+#include "thread_annot_common.h"
+
+extern void bar();
+
+Mutex mu1, mu2;
+int a GUARDED_BY(mu1);
+
+void foo(int x) {
+ if (x > 2) {
+ ReleasableMutexLock l(&mu1);
+ if (a < 3) {
+ a = x + 1;
+ l.Release();
+ bar();
+ }
+ else {
+ a = x + 2;
+ }
+ }
+}
+
+void func(int x) {
+ ReleasableMutexLock l(&mu1);
+ ReleasableMutexLock m(&mu2);
+ switch (x) {
+ case 1:
+ {
+ a = x + 1;
+ l.Release();
+ bar();
+ break;
+ }
+ case 3:
+ {
+ a = x + 3;
+ m.Release();
+ break;
+ }
+ case 2:
+ {
+ a = x + 2;
+ l.Release();
+ bar();
+ break;
+ }
+ default:
+ {
+ a = x + 3;
+ break;
+ }
+ }
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/torture/pr40389.C b/gcc-4.4.0/gcc/testsuite/g++.dg/torture/pr40389.C
new file mode 100644
index 000000000..e3ceb1238
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/torture/pr40389.C
@@ -0,0 +1,84 @@
+/* { dg-do run } */
+
+template <typename V> struct S
+{
+ V *f, *l;
+ __attribute__ ((noinline)) S (void) { f = 0, l = 0; }
+ void foo (V *x)
+ {
+ if (x->p != 0)
+ x->p->n = x->n;
+ else
+ f = x->n;
+ if (x->n != 0)
+ x->n->p = x->p;
+ else
+ l = x->p;
+ }
+ __attribute__ ((noinline)) void bar (V *x)
+ {
+ x->n = 0;
+ x->p = l;
+ if (l != 0)
+ l->n = x;
+ else
+ f = x;
+ l = x;
+ }
+};
+
+struct H;
+
+struct A
+{
+ S <H> k;
+};
+
+struct H
+{
+ A *a;
+ H *p, *n;
+ __attribute__ ((noinline)) H (void) { p = 0, n = 0, a = 0; }
+ __attribute__ ((noinline)) H (A *b) : a (b)
+ {
+ p = 0;
+ n = 0;
+ if (a != 0)
+ a->k.bar (this);
+ }
+ __attribute__ ((noinline)) H (const H &h) : a (h.a)
+ {
+ p = 0;
+ n = 0;
+ if (a != 0)
+ a->k.bar (this);
+ }
+ ~H (void) { if (a != 0) a->k.foo (this); }
+ H &operator= (const H &o)
+ {
+ if (a != 0 || &o == this)
+ __builtin_abort ();
+ a = o.a;
+ if (a != 0)
+ a->k.bar (this);
+ return *this;
+ }
+};
+
+__attribute__ ((noinline))
+H baz (void)
+{
+ return H (new A);
+}
+
+H g;
+
+int
+main (void)
+{
+ g = baz ();
+ if (g.a->k.f != &g)
+ __builtin_abort ();
+ return 0;
+}
+
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C b/gcc-4.4.0/gcc/testsuite/g++.dg/tree-prof/dom-invalid.C
index 5513d3650..866b4d515 100644
--- a/gcc-4.4.0/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/tree-prof/dom-invalid.C
@@ -1,7 +1,6 @@
// PR tree-optimization/39557
// invalid post-dom info leads to infinite loop
-// { dg-do run }
-// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fno-rtti" }
+// { dg-options "-Wall -fno-exceptions -O2 -fno-rtti" }
struct C
{
@@ -49,4 +48,4 @@ main ()
{
E e;
e.bar ();
-} // { dg-message "note: file" "" }
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_a.C b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_a.C
new file mode 100644
index 000000000..58bb9c5d4
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_a.C
@@ -0,0 +1,63 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+typedef long long int64;
+void incr ();
+bool is_valid (int);
+int get_time ();
+
+class A
+{
+public:
+ A ();
+ ~A () {
+ if (I) delete I;
+ }
+
+private:
+ int* I;
+};
+
+bool get_url (A *);
+
+class M {
+
+ public:
+__attribute__ ((always_inline)) int GetC (int *c) {
+
+ A details_str;
+ if (!get_url (&details_str))
+ {
+ incr ();
+ return 1;
+ }
+
+ *c = get_time ();
+ return -1;
+ }
+
+ void do_sth();
+ void do_sth2();
+
+ void P (int64 t)
+ {
+ int cc; /* { dg-bogus "uninitialized" "uninitialized variable warning" } */
+ if (GetC (&cc) >= 0 )
+ return;
+
+ if (t && cc <= 0 ) /* { dg-bogus "uninitialized" "uninitialized variable warning" } */
+ {
+ this->do_sth();
+ return;
+ }
+
+ do_sth2();
+ }
+};
+
+M* m;
+void foo(int x)
+{
+ m = new M;
+ m->P(x);
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_b.C b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_b.C
new file mode 100644
index 000000000..0d5b71ec8
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-1_b.C
@@ -0,0 +1,63 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+typedef long long int64;
+void incr ();
+bool is_valid (int);
+int get_time ();
+
+class A
+{
+public:
+ A ();
+ ~A () {
+ if (I) delete I;
+ }
+
+private:
+ int* I;
+};
+
+bool get_url (A *);
+
+class M {
+
+ public:
+__attribute__ ((always_inline)) int GetC (int *c) {
+
+ A details_str;
+ if (!get_url (&details_str))
+ {
+ incr ();
+ return 1;
+ }
+
+ *c = get_time ();
+ return -1;
+ }
+
+ void do_sth();
+ void do_sth2();
+
+ void P (int64 t)
+ {
+ int cc; /* { dg-excess-errors "note: 'cc' was declared here" } */
+ if (GetC (&cc) <= 0 ) /* return flag checked wrongly */
+ return;
+
+ if (t && cc <= 0 ) /* { dg-warning "uninitialized" "uninitialized variable warning" } */
+ {
+ this->do_sth();
+ return;
+ }
+
+ do_sth2();
+ }
+};
+
+M* m;
+void foo(int x)
+{
+ m = new M;
+ m->P(x);
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_a.C b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_a.C
new file mode 100644
index 000000000..918c94375
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_a.C
@@ -0,0 +1,62 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+typedef long long int64;
+void incr ();
+bool is_valid (int);
+int get_time ();
+
+class A
+{
+public:
+ A ();
+ ~A () {
+ if (I) delete I;
+ }
+
+private:
+ int* I;
+};
+
+bool get_url (A *);
+
+class M {
+
+ public:
+__attribute__ ((always_inline)) bool GetC (int *c) {
+
+ A details_str;
+ if (get_url (&details_str))
+ {
+ *c = get_time ();
+ return true;
+ }
+
+ return false;
+ }
+
+ void do_sth();
+ void do_sth2();
+
+ void P (int64 t)
+ {
+ int cc;
+ if (!GetC (&cc)) /* return flag checked properly */
+ return;
+
+ if (cc <= 0) /* { dg-bogus "uninitialized" "uninitialized variable warning" } */
+ {
+ this->do_sth();
+ return;
+ }
+
+ do_sth2();
+ }
+};
+
+M* m;
+void foo(int x)
+{
+ m = new M;
+ m->P(x);
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_b.C b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_b.C
new file mode 100644
index 000000000..7259d8f95
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-2_b.C
@@ -0,0 +1,62 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+typedef long long int64;
+void incr ();
+bool is_valid (int);
+int get_time ();
+
+class A
+{
+public:
+ A ();
+ ~A () {
+ if (I) delete I;
+ }
+
+private:
+ int* I;
+};
+
+bool get_url (A *);
+
+class M {
+
+ public:
+__attribute__ ((always_inline)) bool GetC (int *c) {
+
+ A details_str;
+ if (get_url (&details_str))
+ {
+ *c = get_time ();
+ return true;
+ }
+
+ return false;
+ }
+
+ void do_sth();
+ void do_sth2();
+
+ void P (int64 t)
+ {
+ int cc; /* { dg-excess-errors "note" } */
+ if (GetC (&cc)) /* return flag checked wrongly */
+ return;
+
+ if (cc <= 0) /* { dg-warning "uninitialized" "uninitialized variable warning" } */
+ {
+ this->do_sth();
+ return;
+ }
+
+ do_sth2();
+ }
+};
+
+M* m;
+void foo(int x)
+{
+ m = new M;
+ m->P(x);
+}
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_a.cc b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_a.cc
new file mode 100644
index 000000000..835cdbae3
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_a.cc
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+extern int bar();
+int foo(void)
+{
+ for (;;) {
+ int err = ({int _err; /* { dg-bogus "uninitialized" "false warning" } */
+ for (int i = 0; i < 16; ++i) {
+ _err = 17;
+ _err = bar();
+ }
+ _err; /* { dg-bogus "uninitialized" "false warning" } */
+ });
+
+ if (err == 0) return 17;
+ }
+
+ return 18;
+}
+
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.cc b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.cc
new file mode 100644
index 000000000..e4ef3d22c
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.cc
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+extern int bar();
+int foo(int n)
+{
+ for (;;) {
+ int err = ({int _err;
+ for (int i = 0; i < n; ++i) {
+ _err = 17;
+ _err = bar();
+ }
+ _err;
+ }); /* { dg-warning "uninitialized" "warn on _err" } */
+
+ if (err == 0) return 17;
+ }
+
+ return 18;
+}
+
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_c.cc b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_c.cc
new file mode 100644
index 000000000..7f6b41d31
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop-1_c.cc
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+extern int bar();
+int foo(int n, int m)
+{
+ for (;;) {
+ int err = ({int _err;
+ for (int i = 0; i < 16; ++i) {
+ if (m+i > n)
+ break;
+ _err = 17;
+ _err = bar();
+ }
+ _err;
+ });
+
+ if (err == 0) return 17; }); /* { dg-warning "uninitialized" "warn on _err" } */
+ }
+
+ return 18;
+}
+
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop_1.cc b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop_1.cc
new file mode 100644
index 000000000..835cdbae3
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/uninit-pred-loop_1.cc
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2" } */
+
+extern int bar();
+int foo(void)
+{
+ for (;;) {
+ int err = ({int _err; /* { dg-bogus "uninitialized" "false warning" } */
+ for (int i = 0; i < 16; ++i) {
+ _err = 17;
+ _err = bar();
+ }
+ _err; /* { dg-bogus "uninitialized" "false warning" } */
+ });
+
+ if (err == 0) return 17;
+ }
+
+ return 18;
+}
+
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" } */