From: Volker Reichelt Date: Fri, 2 Sep 2005 09:15:10 +0000 (+0000) Subject: Backport: X-Git-Tag: releases/gcc-3.4.5~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2cb03a81a5b38086cc6c2bba5c8d97d0b47f602;p=thirdparty%2Fgcc.git Backport: 2004-11-25 Mark Mitchell PR c++/18445 * class.c (instantiate_type): Treat NON_DEPENDENT_EXPRs with unknown_type as non matching. * pt.c (build_non_dependent_expr): Do not build a NON_DEPENDENT_EXPR for a VAR_DECL. * g++.dg/template/crash28.C: New test. From-SVN: r103767 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 20484b9b84e6..211c9db75cc0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2005-09-02 Volker Reichelt + + Backport: + + 2004-11-25 Mark Mitchell + PR c++/18445 + * class.c (instantiate_type): Treat NON_DEPENDENT_EXPRs with + unknown_type as non matching. + * pt.c (build_non_dependent_expr): Do not build a + NON_DEPENDENT_EXPR for a VAR_DECL. + 2005-09-01 Volker Reichelt Backport: diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 09daf118a80f..8be36a04dcf9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6030,6 +6030,15 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) if (TREE_CODE (rhs) == BASELINK) rhs = BASELINK_FUNCTIONS (rhs); + /* If we are in a template, and have a NON_DEPENDENT_EXPR, we cannot + deduce any type information. */ + if (TREE_CODE (rhs) == NON_DEPENDENT_EXPR) + { + if (flags & tf_error) + error ("not enough type information"); + return error_mark_node; + } + /* We don't overwrite rhs if it is an overloaded function. Copying it would destroy the tree link. */ if (TREE_CODE (rhs) != OVERLOAD) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 25e512e06088..c3c982485393 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12242,6 +12242,9 @@ build_non_dependent_expr (tree expr) || TREE_CODE (inner_expr) == TEMPLATE_ID_EXPR || TREE_CODE (inner_expr) == OFFSET_REF) return expr; + /* There is no need to return a proxy for a variable. */ + if (TREE_CODE (expr) == VAR_DECL) + return expr; /* Preserve string constants; conversions from string constants to "char *" are allowed, even though normally a "const char *" cannot be used to initialize a "char *". */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b533b210b332..764e589c2ea0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-09-02 Volker Reichelt + + Backport: + + 2004-11-25 Mark Mitchell + PR c++/18445 + * g++.dg/template/crash28.C: New test. + 2005-09-01 Jakub Jelinek PR rtl-optimization/23478 diff --git a/gcc/testsuite/g++.dg/template/crash28.C b/gcc/testsuite/g++.dg/template/crash28.C index e8b2bbb29853..1ffa66fc7b9a 100644 --- a/gcc/testsuite/g++.dg/template/crash28.C +++ b/gcc/testsuite/g++.dg/template/crash28.C @@ -9,5 +9,5 @@ template void f() { a ex; - g(ex.what); // { dg-error "" } + g(ex.what); // { dg-error "not enough type information" } }