summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-08 09:02:54 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-08 09:02:54 +0000
commit9e3359da54ff7d68b6811c69d68b35a037bc10f3 (patch)
treed236987c163df76b8b17aa8e1b4db328dc1ceb37 /gcc/testsuite/g++.dg
parent4cb0c64a22e7e7df9b2e34f4fbd3a17443a61178 (diff)
downloadgcc-9e3359da54ff7d68b6811c69d68b35a037bc10f3.tar.gz
2009-06-08 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r148271 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@148272 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/template/error38.C2
-rw-r--r--gcc/testsuite/g++.dg/torture/pr32950.C19
-rw-r--r--gcc/testsuite/g++.dg/torture/pr40323.C68
-rw-r--r--gcc/testsuite/g++.dg/torture/pr40335.C16
-rw-r--r--gcc/testsuite/g++.dg/warn/Wswitch-3.C37
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-label-1.C28
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-label-2.C13
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-label-3.C51
8 files changed, 234 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/error38.C b/gcc/testsuite/g++.dg/template/error38.C
index e26345f29a3..6c25b9f9c0f 100644
--- a/gcc/testsuite/g++.dg/template/error38.C
+++ b/gcc/testsuite/g++.dg/template/error38.C
@@ -26,6 +26,7 @@ void f (T &t, int = 0); // { dg-message "" }
typedef int myint;
myint i;
+myint *p;
int main()
{
@@ -34,4 +35,5 @@ int main()
a.g(); // { dg-error "" }
f(i); // { dg-error "" }
+ f(p); // { dg-error "" }
}
diff --git a/gcc/testsuite/g++.dg/torture/pr32950.C b/gcc/testsuite/g++.dg/torture/pr32950.C
new file mode 100644
index 00000000000..8d64296e40b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr32950.C
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+struct A
+{
+ __complex__ double c;
+};
+
+struct B
+{
+ A a;
+ B(A x) : a(x) {}
+ void foo();
+};
+
+void bar()
+{
+ B b = A();
+ B(b).foo();
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr40323.C b/gcc/testsuite/g++.dg/torture/pr40323.C
new file mode 100644
index 00000000000..adecf7fe5f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr40323.C
@@ -0,0 +1,68 @@
+/* Testcase for PR 40323. */
+/* { dg-do compile } */
+/* { dg-options "-fno-early-inlining" } */
+/* { dg-options "-fno-early-inlining -fpie" { target { ! nonpic } } } */
+
+extern void do_something (const char *, int);
+
+class Parent
+{
+private:
+ const char *data;
+
+public:
+ Parent (const char *d) : data(d)
+ {}
+
+ int funcOne (int delim) const;
+};
+
+class AnotherParent
+{
+private:
+ double d;
+public:
+ AnotherParent (void) : d(0)
+ {}
+};
+
+
+class Child : public AnotherParent, Parent
+{
+private:
+ int zzz;
+public:
+ Child (const char *d) : Parent(d)
+ {}
+};
+
+
+int Parent::funcOne (int delim) const
+{
+ int i;
+ for (i = 0; i < delim; i++)
+ do_something(data, i);
+
+ return 1;
+}
+
+int docalling (int (Child::* f)(int delim) const)
+{
+ Child S ("muhehehe");
+
+ return (S.*f)(4);
+}
+
+typedef int (Parent::* my_mp_type)(int delim);
+
+int main (int argc, char *argv[])
+{
+ int i;
+ int (Parent::* f)(int ) const;
+ int (Child::* g)(int ) const;
+
+ f = &Parent::funcOne;
+ g = (int (Child::* )(int) const) f;
+ i = docalling (g);
+ return i;
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr40335.C b/gcc/testsuite/g++.dg/torture/pr40335.C
new file mode 100644
index 00000000000..14ea95d4086
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr40335.C
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+extern "C" void abort (void);
+int
+main (void)
+{
+ int i = -1;
+ switch ((signed char) i)
+ {
+ case 255: /* { dg-bogus "exceeds maximum value" "" { xfail *-*-* } } */
+ abort ();
+ default:
+ break;
+ }
+}
+
diff --git a/gcc/testsuite/g++.dg/warn/Wswitch-3.C b/gcc/testsuite/g++.dg/warn/Wswitch-3.C
new file mode 100644
index 00000000000..df1f8956dad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wswitch-3.C
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-Wswitch" } */
+
+enum E { A, B, C, D, E, F };
+
+int
+f1 (enum E e)
+{
+ switch (e)
+ {
+ case A: return 1;
+ case B: return 2;
+ case C: return 3;
+ case D: return 4;
+ case E: return 5;
+ case F: return 6;
+ case 7: return 7; /* { dg-warning "not in enumerated type" } */
+ }
+ return 0;
+}
+
+int
+f2 (enum E e)
+{
+ switch (e)
+ {
+ case A: return 1;
+ case B: return 2;
+ case C: return 3;
+ case D: return 4;
+ case E: return 5;
+ case F: return 6;
+ case 7: return 7; /* { dg-warning "not in enumerated type" } */
+ default: return 8;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-label-1.C b/gcc/testsuite/g++.dg/warn/Wunused-label-1.C
new file mode 100644
index 00000000000..96f49b321cd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-label-1.C
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-Wunused-label" }
+
+extern void f9();
+
+void
+f1()
+{
+ l1: f9(); // { dg-warning "not used" }
+ l3: ; f9(); // { dg-warning "not used" }
+ l4: __attribute__ ((unused)) ; f9();
+}
+
+void
+f2()
+{
+ label: __attribute ((unused)) ;
+}
+
+void
+f3()
+{
+ // The next line would be OK in C but is a syntax error in C++.
+ l2: __attribute__ ((unused)) f9(); // { dg-error "expected" }
+ // We still get an unused label warning--this is
+ // optional and can be removed if it ever changes.
+ // { dg-warning "not used" "expected" { target *-*-* } 24 }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-label-2.C b/gcc/testsuite/g++.dg/warn/Wunused-label-2.C
new file mode 100644
index 00000000000..a53fdedf317
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-label-2.C
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+// If __attribute__ ((unused)) follows a label and precedes a
+// declaration, we should get a warning for the label, not the
+// declaration.
+
+void
+f1()
+{
+ int i1; // { dg-warning "unused variable" }
+ l1: __attribute__ ((unused)) int i2; // { dg-warning "label \[^\n\]* not used" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-label-3.C b/gcc/testsuite/g++.dg/warn/Wunused-label-3.C
new file mode 100644
index 00000000000..7479ca20c37
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-label-3.C
@@ -0,0 +1,51 @@
+// { dg-do compile }
+// { dg-options "-Wunused-label" }
+
+extern void f9();
+
+template<int i>
+void
+f1()
+{
+ if (i)
+ return;
+
+ l1: f9(); // { dg-warning "not used" }
+ l3: ; f9(); // { dg-warning "not used" }
+ l4: __attribute__ ((unused)) ; f9();
+}
+
+template
+void f1<0>();
+
+template<int i>
+void
+f2()
+{
+ if (i)
+ return;
+
+ l1: f9(); // { dg-warning "not used" }
+ l3: ; f9(); // { dg-warning "not used" }
+ l4: __attribute__ ((unused)) ; f9();
+}
+
+template
+void f2<1>();
+
+template<int i>
+void
+f3()
+{
+ void* lab;
+ l1: f9();
+ l2: __attribute__ ((unused)) ; f9();
+ lab = i ? &&l1 : &&l2;
+ goto *lab;
+}
+
+template
+void f3<0>();
+
+template
+void f3<1>();