]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/38030, 38850, 39070
authorJason Merrill <jason@redhat.com>
Fri, 3 Apr 2009 18:04:39 +0000 (14:04 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 3 Apr 2009 18:04:39 +0000 (14:04 -0400)
        PR c++/38030, 38850, 39070
        * pt.c (type_dependent_expression_p_push): New fn.
        (tsubst_copy_and_build) [CALL_EXPR]: Only do arg-dep lookup when the
        substitution makes the call non-dependent.  Preserve koenig_p.
        * parser.c (cp_parser_postfix_expression): Only do arg-dep lookup
        for non-dependent calls.
        * semantics.c (finish_call_expr): Revert earlier changes.
        * cp-tree.h: Revert change to finish_call_expr prototype.

From-SVN: r145511

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c

index 487da5a513e1d49fbfbad036d510796e63a473f7..68ecd5836e4905c9da8f1704c41aa5616c408961 100644 (file)
@@ -1,3 +1,14 @@
+2009-03-30  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38030, 38850, 39070
+       * pt.c (type_dependent_expression_p_push): New fn.
+       (tsubst_copy_and_build) [CALL_EXPR]: Only do arg-dep lookup when the
+       substitution makes the call non-dependent.  Preserve koenig_p.
+       * parser.c (cp_parser_postfix_expression): Only do arg-dep lookup
+       for non-dependent calls.
+       * semantics.c (finish_call_expr): Revert earlier changes.
+       * cp-tree.h: Revert change to finish_call_expr prototype.
+
 2009-03-26  Ben Elliston  <bje@au.ibm.com>
 
        Backport from mainline:
index 0872280a39b6980813d61014687eb76ecdeee8f3..bf117cc42db30cb48a29c006bc634dbc62a4bde6 100644 (file)
@@ -4465,6 +4465,7 @@ extern bool dependent_template_p          (tree);
 extern bool dependent_template_id_p            (tree, tree);
 extern bool type_dependent_expression_p                (tree);
 extern bool any_type_dependent_arguments_p      (const_tree);
+extern bool type_dependent_expression_p_push   (tree);
 extern bool value_dependent_expression_p       (tree);
 extern bool any_value_dependent_elements_p      (const_tree);
 extern tree resolve_typename_type              (tree, bool);
@@ -4623,7 +4624,7 @@ extern tree finish_stmt_expr_expr         (tree, tree);
 extern tree finish_stmt_expr                   (tree, bool);
 extern tree stmt_expr_value_expr               (tree);
 extern tree perform_koenig_lookup              (tree, tree);
-extern tree finish_call_expr                   (tree, tree, bool, int);
+extern tree finish_call_expr                   (tree, tree, bool, bool);
 extern tree finish_increment_expr              (tree, enum tree_code);
 extern tree finish_this_expr                   (void);
 extern tree finish_pseudo_destructor_expr       (tree, tree, tree);
index d4ae9b380b9c60bb4ce40723024c448ea1bd2f38..9393ba436eb9a140092d8c7298b22ec1061a825b 100644 (file)
@@ -4608,8 +4608,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
                    if (args)
                      {
                        koenig_p = true;
-                       postfix_expression
-                         = perform_koenig_lookup (postfix_expression, args);
+                       if (!any_type_dependent_arguments_p (args))
+                         postfix_expression
+                           = perform_koenig_lookup (postfix_expression, args);
                      }
                    else
                      postfix_expression
@@ -4631,8 +4632,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
                    if (!DECL_FUNCTION_MEMBER_P (fn))
                      {
                        koenig_p = true;
-                       postfix_expression
-                         = perform_koenig_lookup (postfix_expression, args);
+                       if (!any_type_dependent_arguments_p (args))
+                         postfix_expression
+                           = perform_koenig_lookup (postfix_expression, args);
                      }
                  }
              }
index 7eaf68b18d893f1efaa6d666a2f09e254ab15434..ded2b2f8c7a6c39b439c834b0be1d847452e5302 100644 (file)
@@ -11032,7 +11032,11 @@ tsubst_copy_and_build (tree t,
                    not appropriate, even if an unqualified-name was used
                    to denote the function.  */
                 && !DECL_FUNCTION_MEMBER_P (get_first_fn (function)))
-               || TREE_CODE (function) == IDENTIFIER_NODE))
+               || TREE_CODE (function) == IDENTIFIER_NODE)
+           /* Only do this when substitution turns a dependent call
+              into a non-dependent call.  */
+           && type_dependent_expression_p_push (t)
+           && !any_type_dependent_arguments_p (call_args))
          function = perform_koenig_lookup (function, call_args);
 
        if (TREE_CODE (function) == IDENTIFIER_NODE)
@@ -11061,12 +11065,9 @@ tsubst_copy_and_build (tree t,
                       qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL,
                       /*fn_p=*/NULL));
          }
-       /* Pass -1 for koenig_p so that build_new_function_call will
-          allow hidden friends found by arg-dependent lookup at template
-          parsing time.  */
        return finish_call_expr (function, call_args,
                                 /*disallow_virtual=*/qualified_p,
-                                /*koenig_p*/-1);
+                                koenig_p);
       }
 
     case COND_EXPR:
@@ -15959,6 +15960,19 @@ type_dependent_expression_p (tree expression)
   return (dependent_type_p (TREE_TYPE (expression)));
 }
 
+/* Like type_dependent_expression_p, but it also works while not processing
+   a template definition, i.e. during substitution or mangling.  */
+
+bool
+type_dependent_expression_p_push (tree expr)
+{
+  bool b;
+  ++processing_template_decl;
+  b = type_dependent_expression_p (expr);
+  --processing_template_decl;
+  return b;
+}
+
 /* Returns TRUE if ARGS (a TREE_LIST of arguments to a function call)
    contains a type-dependent expression.  */
 
index 6df17c6bf7156271ac9ac6466a1ec106218b2455..1d5961838de5333e25e7c3d202fa2bbfe39de460 100644 (file)
@@ -1832,14 +1832,10 @@ perform_koenig_lookup (tree fn, tree args)
    qualified.  For example a call to `X::f' never generates a virtual
    call.)
 
-   KOENIG_P is 1 if we want to perform argument-dependent lookup,
-   -1 if we don't, but we want to accept functions found by previous
-   argument-dependent lookup, and 0 if we want nothing to do with it.
-
    Returns code for the call.  */
 
 tree
-finish_call_expr (tree fn, tree args, bool disallow_virtual, int koenig_p)
+finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
 {
   tree result;
   tree orig_fn;
@@ -1861,7 +1857,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, int koenig_p)
          || any_type_dependent_arguments_p (args))
        {
          result = build_nt_call_list (fn, args);
-         KOENIG_LOOKUP_P (result) = koenig_p > 0;
+         KOENIG_LOOKUP_P (result) = koenig_p;
          if (cfun)
            {
              do
@@ -1950,7 +1946,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, int koenig_p)
 
       if (!result)
        /* A call to a namespace-scope function.  */
-       result = build_new_function_call (fn, args, koenig_p != 0);
+       result = build_new_function_call (fn, args, koenig_p);
     }
   else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR)
     {
@@ -1976,9 +1972,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, int koenig_p)
   if (processing_template_decl)
     {
       result = build_call_list (TREE_TYPE (result), orig_fn, orig_args);
-      /* Don't repeat arg-dependent lookup at instantiation time if this call
-         is not type-dependent.  */
-      KOENIG_LOOKUP_P (result) = 0;
+      KOENIG_LOOKUP_P (result) = koenig_p;
     }
   return result;
 }