[C++ RFC / Patch] PR 51213 ("access control under SFINAE")

Jason Merrill jason@redhat.com
Tue Jul 17 14:11:00 GMT 2012


On 07/17/2012 08:45 AM, Paolo Carlini wrote:
> -check_default_argument (tree decl, tree arg)
> +check_default_argument (tree decl, tree arg, tsubst_flags_t complain)

Hmm, I don't think substitution of default arguments can cause deduction 
failure; it happens after we've chosen which function to call.  What was 
the motivation for the default argument changes?

> +    tmp = error_mark_node;

Let's use a more informative name than "tmp" for these flags.

> -void
> -perform_deferred_access_checks (void)
> +bool
> +perform_deferred_access_checks (tsubst_flags_t complain)

Need to document what the return value means.

> -  if (complain & tf_error)
> -    perform_or_defer_access_check (TYPE_BINFO (context), t, t);
>
> +  if (!perform_or_defer_access_check (TYPE_BINFO (context), t, t, complain))
> +    return error_mark_node;

These changes along with the enforce_access handling of cxx_dialect 
break C++03 code that currently works, such as

template <class T>
class A
{
   typedef T I;
};

template <class T>
void f(typename T::I);

template <class T>
void f(int);

int main()
{
   f<A<float> > (1);
}

Under the C++03 rules, we don't get access errors when generating 
overload candidates, we get them when the function is instantiated (i.e. 
in instantiate_decl).

Hmm, now that I look at the code in instantiate_decl for re-substituting 
to get additional errors, I guess I should have factored that code out 
into a separate function and used it in the access7 patch rather than 
add handling of FNDECL_RECHECK_ACCESS_P in tsubst_decl.

Jason



More information about the Gcc-patches mailing list