From: Jason Merrill Date: Wed, 31 May 2017 17:11:17 +0000 (-0400) Subject: PR c++/80840 - ICE with constexpr and reference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=049a5d31b9fce6c40721e8c07573c34df9ed9eec;p=gcc.git PR c++/80840 - ICE with constexpr and reference * pt.c (convert_nontype_argument): Don't test whether a decl is value-dependent when binding to a reference. From-SVN: r248749 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72a56f7553b..bbb6a533d85 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-05-31 Jason Merrill + + PR c++/80840 - ICE with constexpr and reference + * pt.c (convert_nontype_argument): Don't test whether a decl is + value-dependent when binding to a reference. + 2017-05-31 Nathan Sidwell * cp-tree.h (lang_decl_slector): New enum. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8f699395d48..a04f2e0a762 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6749,7 +6749,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) } } - if (!value_dependent_expression_p (expr)) + if (TYPE_REF_OBJ_P (TREE_TYPE (expr)) + && value_dependent_expression_p (expr)) + /* OK, dependent reference. We don't want to ask whether a DECL is + itself value-dependent, since what we want here is its address. */; + else { if (!DECL_P (expr)) { @@ -6771,8 +6775,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; } - expr = build_nop (type, build_address (expr)); + expr = build_address (expr); } + + if (!same_type_p (type, TREE_TYPE (expr))) + expr = build_nop (type, expr); } /* [temp.arg.nontype]/5, bullet 4 diff --git a/gcc/testsuite/g++.dg/template/ref10.C b/gcc/testsuite/g++.dg/template/ref10.C new file mode 100644 index 00000000000..60e91d053a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ref10.C @@ -0,0 +1,13 @@ +// PR c++/80840 +// { dg-do compile { target c++11 } } + +template +struct Just; + +template +struct Number { + static constexpr double value = X; + using result = Just; +}; + +int main() {}