From 638dd8fc323c9eec40f19244afbd965173bf35eb Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 23 Jul 1999 04:32:17 +0000 Subject: [PATCH] pt.c (convert_nontype_argument): Don't call decl_constant_value if we're converting to a reference type. * pt.c (convert_nontype_argument): Don't call decl_constant_value if we're converting to a reference type. From-SVN: r28224 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 9 ++++++--- gcc/testsuite/g++.old-deja/g++.oliva/template4.C | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c111a865279..78440927368 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 1999-07-22 Mark Mitchell + * pt.c (convert_nontype_argument): Don't call decl_constant_value + if we're converting to a reference type. + * call.c (NEED_TEMPORARY_P): New macro. (standard_conversion): Set it, for derived-to-base conversions. (reference_related_p): New function. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0744812cfc7..06b6c1343a8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2681,9 +2681,12 @@ convert_nontype_argument (type, expr) --a pointer to member expressed as described in _expr.unary.op_. */ - /* An integral constant-expression can include const variables - or enumerators. */ - if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr)) + /* An integral constant-expression can include const variables or + enumerators. Simplify things by folding them to their values, + unless we're about to bind the declaration to a reference + parameter. */ + if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr) + && TREE_CODE (type) != REFERENCE_TYPE) expr = decl_constant_value (expr); if (is_overloaded_fn (expr)) diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template4.C b/gcc/testsuite/g++.old-deja/g++.oliva/template4.C index 5d7f7a638e1..4c2afc78d34 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/template4.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template4.C @@ -17,4 +17,4 @@ extern const int c; X z; // ok, c has external linkage extern const int c = 3; -X z_; // gets bogus error - using c as constant - XFAIL *-*-* +X z_; // gets bogus error - using c as constant -- 2.30.2