summaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-19 19:00:21 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-19 19:00:21 +0000
commit51120e849d2624898aae65cbb70a33aff9da7236 (patch)
tree5619684f985ef38c0ced0fa21b91f394c85a805c /gcc/cp/pt.c
parent45dc77fb3b3abb81650a1206a744c42c8de6958c (diff)
downloadgcc-51120e849d2624898aae65cbb70a33aff9da7236.tar.gz
PR c++/59759
* pt.c (convert_template_argument): Handle VAR_DECL properly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232580 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6062ebe50a6..ae60f1c2d0a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19928,11 +19928,20 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
return unify_template_argument_mismatch (explain_p, parm, arg);
case VAR_DECL:
- /* A non-type template parameter that is a variable should be a
- an integral constant, in which case, it whould have been
- folded into its (constant) value. So we should not be getting
- a variable here. */
- gcc_unreachable ();
+ /* We might get a variable as a non-type template argument in parm if the
+ corresponding parameter is type-dependent. Make any necessary
+ adjustments based on whether arg is a reference. */
+ if (CONSTANT_CLASS_P (arg))
+ parm = fold_non_dependent_expr (parm);
+ else if (REFERENCE_REF_P (arg))
+ {
+ tree sub = TREE_OPERAND (arg, 0);
+ STRIP_NOPS (sub);
+ if (TREE_CODE (sub) == ADDR_EXPR)
+ arg = TREE_OPERAND (sub, 0);
+ }
+ /* Now use the normal expression code to check whether they match. */
+ goto expr;
case TYPE_ARGUMENT_PACK:
case NONTYPE_ARGUMENT_PACK:
@@ -19965,7 +19974,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
if (is_overloaded_fn (parm) || type_unknown_p (parm))
return unify_success (explain_p);
gcc_assert (EXPR_P (parm));
-
+ expr:
/* We must be looking at an expression. This can happen with
something like: