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
This commit is contained in:
parent
ff14c1f700
commit
0de2d392b0
@ -1,5 +1,9 @@
|
||||
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
|
||||
* pt.c (tsubst_baselink): tsubst the name.
|
||||
|
||||
|
@ -11368,18 +11368,26 @@ cp_parser_template_argument (cp_parser* parser)
|
||||
cp_parser_abort_tentative_parse (parser);
|
||||
else
|
||||
{
|
||||
tree probe;
|
||||
|
||||
if (TREE_CODE (argument) == INDIRECT_REF)
|
||||
{
|
||||
gcc_assert (REFERENCE_REF_P (argument));
|
||||
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
|
||||
valid constant-expression, so no error is issued here
|
||||
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);
|
||||
}
|
||||
else if (is_overloaded_fn (argument))
|
||||
|
@ -1,5 +1,8 @@
|
||||
2009-11-09 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/41972
|
||||
* g++.dg/template/ref4.C: New.
|
||||
|
||||
PR c++/41994
|
||||
* g++.dg/template/conv10.C: New.
|
||||
|
||||
|
12
gcc/testsuite/g++.dg/template/ref4.C
Normal file
12
gcc/testsuite/g++.dg/template/ref4.C
Normal file
@ -0,0 +1,12 @@
|
||||
// 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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user