pt.c (convert_nontype_argument): Don't call decl_constant_value if we're converting...
authorMark Mitchell <mark@codesourcery.com>
Fri, 23 Jul 1999 04:32:17 +0000 (04:32 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 23 Jul 1999 04:32:17 +0000 (04:32 +0000)
* 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
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.oliva/template4.C

index c111a86527961cd295b930eacb78106c59a183b4..7844092736807e0437da7177391d89a949e26737 100644 (file)
@@ -1,5 +1,8 @@
 1999-07-22  Mark Mitchell  <mark@codesourcery.com>
 
+       * 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.
index 0744812cfc752932f9436ae1fdbabd018379bb24..06b6c1343a857803c878d34f8fab27fd20b8aacd 100644 (file)
@@ -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))
index 5d7f7a638e17e302478688c14052b4f0d69d597b..4c2afc78d34ed520c2b5dd6d8ed63a41f185b917 100644 (file)
@@ -17,4 +17,4 @@ extern const int c;
 X<c> z; // ok, c has external linkage
 
 extern const int c = 3;
-X<c> z_; // gets bogus error - using c as constant - XFAIL *-*-*
+X<c> z_; // gets bogus error - using c as constant