aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2002-12-13 21:58:54 +0000
committerGabriel Dos Reis <gdr@integrable-solutions.net>2002-12-13 21:58:54 +0000
commit8a2aeb32311418d7ce57f7fe3ce2a2720018a3c8 (patch)
tree2199ef403788353883d10b25b9bae81faa2269b7
parent65efb9bf833514b857f9783e5d9af264bb0d3eca (diff)
PR C++/8031
* cvt.c (convert_to_pointer_force): Don't try comparing against erronous type. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@60106 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cvt.c2
-rw-r--r--gcc/testsuite/g++.dg/conversion/to-virtual-base-1.C15
3 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c2627ba6644..096b906a633 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2002-12-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR C++/8031
+ * cvt.c (convert_to_pointer_force): Don't try comparing against
+ erronous type.
+
2002-12-13 Geoffrey Keating <geoffk@apple.com>
* cp-tree.h: Have the multiple-include guards around
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 7e31045a485..97d24202850 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -322,6 +322,8 @@ convert_to_pointer_force (type, expr)
if (binfo)
{
expr = build_base_path (code, expr, binfo, 0);
+ if (expr == error_mark_node)
+ return error_mark_node;
/* Add any qualifier conversions. */
if (!same_type_p (TREE_TYPE (TREE_TYPE (expr)),
TREE_TYPE (type)))
diff --git a/gcc/testsuite/g++.dg/conversion/to-virtual-base-1.C b/gcc/testsuite/g++.dg/conversion/to-virtual-base-1.C
new file mode 100644
index 00000000000..3fa8e418e87
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/to-virtual-base-1.C
@@ -0,0 +1,15 @@
+// Copyright (C) 2002 Free Software Foundation
+// Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+struct A {
+ virtual void f(const A* a) = 0;
+};
+
+struct B : virtual A {
+ virtual void f(const A* a);
+};
+
+void B::f(const A* a)
+{
+ static_cast<const B&>(*a); // { dg-error "" }
+}