aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-10-17 00:17:59 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-10-17 00:17:59 +0000
commit2303a07914bc82ca17706fc15166bf40b940bfa7 (patch)
treec40ac826896b3368eb3837dde85eb3dabae7beaf /gcc
parentf9dd72da28d0932c200fb1885f350e9908186582 (diff)
downloadgcc-2303a07914bc82ca17706fc15166bf40b940bfa7.zip
gcc-2303a07914bc82ca17706fc15166bf40b940bfa7.tar.gz
gcc-2303a07914bc82ca17706fc15166bf40b940bfa7.tar.bz2
re PR c++/7478 (internal compiler error on static_cast inside template)
PR c++/7478 * cvt.c (convert_to_reference): Allow references as the incoming type. PR c++/7478 * g++.dg/template/ref1.C: New test. From-SVN: r58230
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cvt.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/ref1.C3
4 files changed, 22 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 07b8732..80132ef 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2002-10-16 Mark Mitchell <mark@codesourcery.com>
+ PR c++/7478
+ * cvt.c (convert_to_reference): Allow references as the incoming
+ type.
+
+2002-10-16 Mark Mitchell <mark@codesourcery.com>
+
PR c++/7524
* method.c (do_build_assign_ref): Use cp_build_qualified_type, not
build_qualified_type.
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 6905a049e..7e31045 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -473,12 +473,13 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
tree decl;
{
register tree type = TYPE_MAIN_VARIANT (TREE_TYPE (reftype));
- register tree intype = TREE_TYPE (expr);
+ register tree intype;
tree rval = NULL_TREE;
tree rval_as_conversion = NULL_TREE;
int i;
- if (TREE_CODE (type) == FUNCTION_TYPE && intype == unknown_type_node)
+ if (TREE_CODE (type) == FUNCTION_TYPE
+ && TREE_TYPE (expr) == unknown_type_node)
{
expr = instantiate_type (type, expr,
(flags & LOOKUP_COMPLAIN)
@@ -488,6 +489,11 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
intype = TREE_TYPE (expr);
}
+ else
+ {
+ expr = convert_from_reference (expr);
+ intype = TREE_TYPE (expr);
+ }
my_friendly_assert (TREE_CODE (intype) != REFERENCE_TYPE, 364);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 06461f7..3f3cee4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-16 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/7478
+ * g++.dg/template/ref1.C: New test.
+
2002-10-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.c-torture/execute/20020720-1.x: Don't XFAIL for mips.
diff --git a/gcc/testsuite/g++.dg/template/ref1.C b/gcc/testsuite/g++.dg/template/ref1.C
new file mode 100644
index 0000000..3f133d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ref1.C
@@ -0,0 +1,3 @@
+class a {} a1;
+template <a & p> class b { public: b() { static_cast <a &> (p); }; };
+int main() { b <a1> b1; };