re PR c++/65195 (Variable template cannot be used as a function)

PR c++/65195
	PR c++/66619
	* semantics.c (finish_id_expression): Call convert_from_reference
	for variable template.

From-SVN: r226641
This commit is contained in:
Jason Merrill 2015-08-05 13:51:29 -04:00 committed by Jason Merrill
parent 76787f7009
commit 85171e7877
4 changed files with 40 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2015-08-05 Jason Merrill <jason@redhat.com>
PR c++/65195
PR c++/66619
* semantics.c (finish_id_expression): Call convert_from_reference
for variable template.
2015-08-04 Jason Merrill <jason@redhat.com>
* pt.c (lookup_template_class_1): Clear elt.spec.

View File

@ -3564,6 +3564,7 @@ finish_id_expression (tree id_expression,
{
decl = finish_template_variable (decl);
mark_used (decl);
decl = convert_from_reference (decl);
}
else if (scope)
{

View File

@ -0,0 +1,23 @@
// PR c++/65195
// { dg-do compile { target c++14 } }
template<typename T>
T constant {};
template<typename T>
struct foo {
int operator()() const
{ return 3; }
};
template<typename T>
auto& f = constant<foo<T>>;
int main()
{
// fine
auto& ref = f<int>; ref();
// error: f<int> cannot be used as a function
f<int>();
}

View File

@ -0,0 +1,9 @@
// PR c++/66619
// { dg-do compile { target c++14 } }
int y;
template<class T> T val1 = y;
auto&& x1 = val1<int&>;
template<class T> T val2 = 0;
auto&& x2 = val2<int&&>;