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

login
register
mail settings
Submitter Jason Merrill
Date July 19, 2012, 1:35 a.m.
Message ID <50076464.9010208@redhat.com>
Download mbox | patch
Permalink /patch/171860/
State New
Headers show

Comments

Jason Merrill - July 19, 2012, 1:35 a.m.
On 07/12/2012 07:06 PM, Jason Merrill wrote:
> I notice that your patch changes the behavior of C++98/03 mode as well,
> which seems wrong to me; I think this is a big enough change that we
> should limit it to C++11 mode.

...except that I can't figure out what the semantics before this DR were 
really supposed to be; G++, EDG and Clang all handle this stuff 
differently.  After poking at it for a while I think the only sensible 
thing is to have C++03 work the same as C++11.  I've done that, and I'm 
going to check in the full patch.

The first attachment is the full patch; the second is the changes 
relative to your earlier patch.  I changed tf_error to 
tf_warning_or_error, went back to treating C++03 and C++11 the same, 
made the FNDECL_RECHECK_ACCESS_P change I mentioned, and streamlined 
LOOKUP_SPECULATIVE handling.

The third attachment is to fix another problem with my earlier DR 1402 
patch.  I'm applying this one to 4.7 as well.

Finally, the fourth attachment is to remove the substitution checking 
from instantiate_decl, as it seems to be redundant.

Tested x86_64-pc-linux-gnu, applying to trunk.
Paolo Carlini - July 19, 2012, 9:45 a.m.
On 07/19/2012 03:35 AM, Jason Merrill wrote:
> On 07/12/2012 07:06 PM, Jason Merrill wrote:
>> I notice that your patch changes the behavior of C++98/03 mode as well,
>> which seems wrong to me; I think this is a big enough change that we
>> should limit it to C++11 mode.
>
> ...except that I can't figure out what the semantics before this DR 
> were really supposed to be; G++, EDG and Clang all handle this stuff 
> differently.  After poking at it for a while I think the only sensible 
> thing is to have C++03 work the same as C++11.  I've done that, and 
> I'm going to check in the full patch.
>
> The first attachment is the full patch; the second is the changes 
> relative to your earlier patch.  I changed tf_error to 
> tf_warning_or_error, went back to treating C++03 and C++11 the same, 
> made the FNDECL_RECHECK_ACCESS_P change I mentioned, and streamlined 
> LOOKUP_SPECULATIVE handling.
Thanks A LOT!

Cheers,
Paolo.

Patch

commit c871e18c31fd94e9ee7ee983bedf50047dedfe60
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jul 18 18:37:17 2012 -0400

    	* pt.c (instantiate_decl): Don't recheck substitutions.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 65eb2cc..0d25398 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18248,35 +18248,6 @@  instantiate_decl (tree d, int defer_ok,
   if (TREE_CODE (d) == FUNCTION_DECL)
     maybe_instantiate_noexcept (d);
 
-  /* Recheck the substitutions to obtain any warning messages
-     about ignoring cv qualifiers.  Don't do this for artificial decls,
-     as it breaks the context-sensitive substitution for lambda op(). */
-  if (!defer_ok && !DECL_ARTIFICIAL (d))
-    {
-      tree gen = DECL_TEMPLATE_RESULT (gen_tmpl);
-      tree type = TREE_TYPE (gen);
-
-      /* Make sure that we can see identifiers, and compute access
-	 correctly.  D is already the target FUNCTION_DECL with the
-	 right context.  */
-      push_access_scope (d);
-
-      if (TREE_CODE (gen) == FUNCTION_DECL)
-	{
-	  tsubst (DECL_ARGUMENTS (gen), gen_args, tf_warning_or_error, d);
-          tsubst_exception_specification (type, gen_args, tf_warning_or_error,
-                                          d, /*defer_ok*/true);
-	  /* Don't simply tsubst the function type, as that will give
-	     duplicate warnings about poor parameter qualifications.
-	     The function arguments are the same as the decl_arguments
-	     without the top level cv qualifiers.  */
-	  type = TREE_TYPE (type);
-	}
-      tsubst (type, gen_args, tf_warning_or_error, d);
-
-      pop_access_scope (d);
-    }
-
   /* Defer all other templates, unless we have been explicitly
      forbidden from doing so.  */
   if (/* If there is no definition, we cannot instantiate the