Patchwork C++ PATCH for c++/51507 (pack expansion in trailing-return-type)

login
register
mail settings
Submitter Jason Merrill
Date Dec. 23, 2011, 9:58 p.m.
Message ID <4EF4F989.6090207@redhat.com>
Download mbox | patch
Permalink /patch/133144/
State New
Headers show

Comments

Jason Merrill - Dec. 23, 2011, 9:58 p.m.
The existing code to handle pack expansions in trailing-return-type 
assumed that such expansions would only occur inside decltype, which is 
not the case.  This patch fixes the test to check for whether or not 
we're doing the substitution in the context of a function body, and 
fixes at_function_scope_p to properly return false when we're 
substituting deduced arguments into a candidate function template.

Even with the change to at_function_scope_p it was impossible to tell 
that we weren't in function scope when instantiating a function 
declaration as part of overload resolution, so I also changed 
instantiate_template_1 to use push_to_top_level rather than just clear 
processing_template_decl.  In my testing it was enough to just clear 
current_function_decl as well, but since in fact the instantiation 
happens at top level it seems more correct to use push_to_top_level.

The second patch is a bug I noticed in dependent_name while working on 
this patch, though it isn't necessary to this patch; a BASELINK should 
not be considered a dependent name, or we end up treating calls to 
members of different classes as equivalent.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit a02c1be6a5cb39703b715e8b490976e8eacc9431
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Dec 23 13:58:46 2011 -0500

    	* tree.c (dependent_name): OFFSET_REF and BASELINK
    	are not dependent names.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 634c267..dea7632 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1463,6 +1463,8 @@  dependent_name (tree x)
   if (TREE_CODE (x) == IDENTIFIER_NODE)
     return x;
   if (TREE_CODE (x) != COMPONENT_REF
+      && TREE_CODE (x) != OFFSET_REF
+      && TREE_CODE (x) != BASELINK
       && is_overloaded_fn (x))
     return DECL_NAME (get_first_fn (x));
   return NULL_TREE;