re PR c++/56208 (Some classic sfinae cases fail to work due to access problems)
PR c++/56208 * pt.c (fn_type_unification): Discard any access checks from substituting explicit args. From-SVN: r195779
This commit is contained in:
parent
bda9912058
commit
29ef6cd035
|
@ -1,3 +1,9 @@
|
|||
2013-02-05 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/56208
|
||||
* pt.c (fn_type_unification): Discard any access checks from
|
||||
substituting explicit args.
|
||||
|
||||
2013-01-31 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/56162
|
||||
|
|
|
@ -14989,6 +14989,12 @@ fn_type_unification (tree fn,
|
|||
if (fntype == error_mark_node)
|
||||
goto fail;
|
||||
|
||||
/* Throw away these access checks; we'll see them again in
|
||||
instantiate_template and they might have the wrong
|
||||
access path at this point. */
|
||||
pop_deferring_access_checks ();
|
||||
push_deferring_access_checks (dk_deferred);
|
||||
|
||||
/* Place the explicitly specified arguments in TARGS. */
|
||||
for (i = NUM_TMPL_ARGS (explicit_targs); i--;)
|
||||
TREE_VEC_ELT (targs, i) = TREE_VEC_ELT (explicit_targs, i);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// PR c++/56208
|
||||
// { dg-options -std=c++11 }
|
||||
|
||||
struct ostream {
|
||||
ostream& operator<<(int);
|
||||
};
|
||||
|
||||
struct sfinae_base {
|
||||
|
||||
typedef char one;
|
||||
typedef char (&two)[2];
|
||||
|
||||
template<class T>
|
||||
static T make();
|
||||
|
||||
template<unsigned> struct ok { typedef int type; };
|
||||
|
||||
template<class U, class T>
|
||||
static one test(decltype((make<U>() << make<T>()), 0));
|
||||
|
||||
template<class, class>
|
||||
static two test(...);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_printable : private sfinae_base
|
||||
{
|
||||
enum { value = sizeof(test<ostream&, T>(0)) == sizeof(one) };
|
||||
};
|
||||
|
||||
typedef int ok[is_printable<int>::value ? 1 : -1];
|
Loading…
Reference in New Issue