re PR c++/44193 (function types, cv-quals and typename)
PR c++/44193 * pt.c (tsubst) [TYPENAME_TYPE]: Discard cv-quals on function/reference type. From-SVN: r159576
This commit is contained in:
parent
566131c778
commit
a134381373
|
@ -1,3 +1,9 @@
|
|||
2010-05-19 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/44193
|
||||
* pt.c (tsubst) [TYPENAME_TYPE]: Discard cv-quals on
|
||||
function/reference type.
|
||||
|
||||
2010-04-29 Release Manager
|
||||
|
||||
* GCC 4.4.4 released.
|
||||
|
|
12
gcc/cp/pt.c
12
gcc/cp/pt.c
|
@ -9708,6 +9708,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
|||
in_decl, /*entering_scope=*/1);
|
||||
tree f = tsubst_copy (TYPENAME_TYPE_FULLNAME (t), args,
|
||||
complain, in_decl);
|
||||
int quals;
|
||||
|
||||
if (ctx == error_mark_node || f == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
@ -9757,8 +9758,15 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
|||
t, f);
|
||||
}
|
||||
|
||||
return cp_build_qualified_type_real
|
||||
(f, cp_type_quals (f) | cp_type_quals (t), complain);
|
||||
/* cv-quals from the template are discarded when
|
||||
substituting in a function or reference type. */
|
||||
if (TREE_CODE (f) == FUNCTION_TYPE
|
||||
|| TREE_CODE (f) == METHOD_TYPE
|
||||
|| TREE_CODE (f) == REFERENCE_TYPE)
|
||||
quals = cp_type_quals (f);
|
||||
else
|
||||
quals = cp_type_quals (f) | cp_type_quals (t);
|
||||
return cp_build_qualified_type_real (f, quals, complain);
|
||||
}
|
||||
|
||||
case UNBOUND_CLASS_TEMPLATE:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2010-05-19 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/44193
|
||||
* g++.dg/template/fntype1.C: New.
|
||||
|
||||
2010-05-14 Steven G. Kargl <kargl@gcc.gnu.org>
|
||||
|
||||
PR fortran/44135
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
bool f(int i) { return i != 5; }
|
||||
|
||||
template <class X, class P = bool(X)>
|
||||
struct Traits
|
||||
{
|
||||
typedef P type;
|
||||
};
|
||||
|
||||
template <class X, class P = typename Traits<X>::type>
|
||||
struct S
|
||||
{
|
||||
const P& p_;
|
||||
S( const P& p ) : p_(p) {} // const reference
|
||||
};
|
||||
|
||||
template <class X>
|
||||
S<X> make_s(const typename Traits<X>::type & p) // const reference
|
||||
{
|
||||
return S<X>(p); // << HERE
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
make_s<int>(f);
|
||||
}
|
Loading…
Reference in New Issue