From 75c525d71b62065102c3760de9e8015c141cfa3d Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis <gdr@integrable-solutions.net> Date: Fri, 13 Dec 2002 21:58:54 +0000 Subject: [PATCH] re PR c++/8031 (ICE in comptypes, at cp/typeck.c:913) PR C++/8031 * cvt.c (convert_to_pointer_force): Don't try comparing against erronous type. From-SVN: r60106 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cvt.c | 2 ++ .../g++.dg/conversion/to-virtual-base-1.C | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/conversion/to-virtual-base-1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c2627ba66440..096b906a6330 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 7e31045a4854..97d242028504 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 000000000000..3fa8e418e879 --- /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 "" } +} -- GitLab