+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-20 Richard Guenther <rguenther@suse.de>
Backport from mainline
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;
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:
+2010-05-19 Jason Merrill <jason@redhat.com>
+
+ PR c++/44193
+ * g++.dg/template/fntype1.C: New.
+
2010-04-30 DJ Delorie <dj@redhat.com>
* gcc.c-torture/execute/20100430-1.c: New test.
--- /dev/null
+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);
+}
template <typename T> struct B1 : T
{
typedef typename T::L __restrict__ r;// { dg-error "'__restrict__' qualifiers cannot" "" }
- typedef typename T::myT __restrict__ p;// { dg-error "ignoring '__restrict__'" }
+ typedef typename T::myT __restrict__ p;
// The following are DR 295 dependent
typedef typename T::myT volatile *myvolatile;