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:
parent
76787f7009
commit
85171e7877
@ -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.
|
||||
|
@ -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)
|
||||
{
|
||||
|
23
gcc/testsuite/g++.dg/cpp1y/var-templ37.C
Normal file
23
gcc/testsuite/g++.dg/cpp1y/var-templ37.C
Normal 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>();
|
||||
}
|
9
gcc/testsuite/g++.dg/cpp1y/var-templ40.C
Normal file
9
gcc/testsuite/g++.dg/cpp1y/var-templ40.C
Normal 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&&>;
|
Loading…
Reference in New Issue
Block a user