summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/rtti1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/opt/rtti1.C')
-rw-r--r--gcc/testsuite/g++.dg/opt/rtti1.C20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/rtti1.C b/gcc/testsuite/g++.dg/opt/rtti1.C
new file mode 100644
index 000000000..32daaefa6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/rtti1.C
@@ -0,0 +1,20 @@
+// Test that typeid sees through references even when optimizing.
+// { dg-do run }
+// { dg-options "-O2" }
+
+#include <typeinfo>
+
+struct A
+{
+ virtual ~A() { }
+};
+
+class B : public A { };
+
+int main ()
+{
+ B b;
+ A &aref = b;
+
+ return typeid (aref) != typeid (b);
+}