Commit 0de2d392 by Jason Merrill Committed by Jason Merrill

re PR c++/41972 (nondependent static member function as a reference template parameter fails)

	PR c++/41972
	* parser.c (cp_parser_template_argument): Accept SCOPE_REF around
	VAR_DECL.

From-SVN: r154042
parent ff14c1f7
2009-11-09 Jason Merrill <jason@redhat.com> 2009-11-09 Jason Merrill <jason@redhat.com>
PR c++/41972
* parser.c (cp_parser_template_argument): Accept SCOPE_REF around
VAR_DECL.
PR c++/41994 PR c++/41994
* pt.c (tsubst_baselink): tsubst the name. * pt.c (tsubst_baselink): tsubst the name.
......
...@@ -11368,18 +11368,26 @@ cp_parser_template_argument (cp_parser* parser) ...@@ -11368,18 +11368,26 @@ cp_parser_template_argument (cp_parser* parser)
cp_parser_abort_tentative_parse (parser); cp_parser_abort_tentative_parse (parser);
else else
{ {
tree probe;
if (TREE_CODE (argument) == INDIRECT_REF) if (TREE_CODE (argument) == INDIRECT_REF)
{ {
gcc_assert (REFERENCE_REF_P (argument)); gcc_assert (REFERENCE_REF_P (argument));
argument = TREE_OPERAND (argument, 0); argument = TREE_OPERAND (argument, 0);
} }
if (TREE_CODE (argument) == VAR_DECL) /* If we're in a template, we represent a qualified-id referring
to a static data member as a SCOPE_REF even if the scope isn't
dependent so that we can check access control later. */
probe = argument;
if (TREE_CODE (probe) == SCOPE_REF)
probe = TREE_OPERAND (probe, 1);
if (TREE_CODE (probe) == VAR_DECL)
{ {
/* A variable without external linkage might still be a /* A variable without external linkage might still be a
valid constant-expression, so no error is issued here valid constant-expression, so no error is issued here
if the external-linkage check fails. */ if the external-linkage check fails. */
if (!address_p && !DECL_EXTERNAL_LINKAGE_P (argument)) if (!address_p && !DECL_EXTERNAL_LINKAGE_P (probe))
cp_parser_simulate_error (parser); cp_parser_simulate_error (parser);
} }
else if (is_overloaded_fn (argument)) else if (is_overloaded_fn (argument))
......
2009-11-09 Jason Merrill <jason@redhat.com> 2009-11-09 Jason Merrill <jason@redhat.com>
PR c++/41972
* g++.dg/template/ref4.C: New.
PR c++/41994 PR c++/41994
* g++.dg/template/conv10.C: New. * g++.dg/template/conv10.C: New.
......
// PR c++/41972
struct X {
static const double x;
};
template <const double& _test_>
class Foo { };
template <typename _ignore_>
struct Y {
typedef Foo<X::x> type;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment