aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/lto/pr89335_0.C2
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-1.C28
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-2.C29
-rw-r--r--gcc/testsuite/g++.dg/warn/pr83054-2.C44
-rw-r--r--gcc/testsuite/g++.dg/warn/pr83054.C2
5 files changed, 103 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.dg/lto/pr89335_0.C b/gcc/testsuite/g++.dg/lto/pr89335_0.C
index 95bf4b3..76382f8 100644
--- a/gcc/testsuite/g++.dg/lto/pr89335_0.C
+++ b/gcc/testsuite/g++.dg/lto/pr89335_0.C
@@ -9,7 +9,7 @@ public:
virtual ~Container ();
};
-class List : public Container // { dg-lto-message "final would enable devirtualization" }
+class List : public Container
{
};
diff --git a/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-1.C b/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-1.C
new file mode 100644
index 0000000..ce8dc2a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-1.C
@@ -0,0 +1,28 @@
+// PR c++/110057
+/* { dg-do-compile } */
+/* Virtual calls should be devirtualized because we know dynamic type of object in array at compile time */
+/* { dg-options "-O3 -fdump-tree-optimized -fno-inline" } */
+
+class A
+{
+public:
+ virtual ~A()
+ {
+ }
+};
+
+class B : public A
+{
+public:
+ virtual ~B()
+ {
+ }
+};
+
+int main()
+{
+ B b[10];
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-2.C b/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-2.C
new file mode 100644
index 0000000..6b44dc1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/devirt-array-destructor-2.C
@@ -0,0 +1,29 @@
+// PR c++/110057
+/* { dg-do-compile } */
+/* Virtual calls should be devirtualized because we know dynamic type of object in array at compile time */
+/* { dg-options "-O3 -fdump-tree-optimized -fno-inline" } */
+
+class A
+{
+public:
+ virtual ~A()
+ {
+ }
+};
+
+class B : public A
+{
+public:
+ virtual ~B()
+ {
+ }
+};
+
+int main()
+{
+ B* ptr = new B[10];
+ delete[] ptr;
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
diff --git a/gcc/testsuite/g++.dg/warn/pr83054-2.C b/gcc/testsuite/g++.dg/warn/pr83054-2.C
new file mode 100644
index 0000000..6d8216d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr83054-2.C
@@ -0,0 +1,44 @@
+// PR ipa/83054
+// { dg-options "-O3 -Wsuggest-final-types" }
+// { dg-do compile }
+
+// A throwing dtor in C++98 mode changes the warning.
+#if __cplusplus < 201100L
+#define NOTHROW throw()
+#else
+#define NOTHROW noexcept
+#endif
+
+extern "C" int printf (const char *, ...);
+struct foo // { dg-warning "final would enable devirtualization of 1 call" }
+{
+ static int count;
+ void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
+ int x;
+ foo () {
+ x = count++;
+ printf("this %d = %x\n", x, (void *)this);
+ }
+ virtual ~foo () NOTHROW {
+ printf("this %d = %x\n", x, (void *)this);
+ --count;
+ }
+};
+int foo::count;
+
+
+int main ()
+{
+ foo *arr[9];
+ for (int i = 0; i < 9; ++i)
+ arr[i] = new foo();
+ if (foo::count != 9)
+ return 1;
+ for (int i = 0; i < 9; ++i)
+ arr[i]->print(i / 3, i % 3);
+ for (int i = 0; i < 9; ++i)
+ delete arr[i];
+ if (foo::count != 0)
+ return 1;
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/warn/pr83054.C b/gcc/testsuite/g++.dg/warn/pr83054.C
index 5285f94..5a4a6ab 100644
--- a/gcc/testsuite/g++.dg/warn/pr83054.C
+++ b/gcc/testsuite/g++.dg/warn/pr83054.C
@@ -10,7 +10,7 @@
#endif
extern "C" int printf (const char *, ...);
-struct foo // { dg-warning "final would enable devirtualization of 5 calls" }
+struct foo
{
static int count;
void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }