diff mbox

[C++] PR 59165 (aka Core/1442)

Message ID 52A70F0B.2030308@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 10, 2013, 12:54 p.m. UTC
Hi,

as far as I can see, this bug asks for the implementation of Core/1442, 
thus don't do a special Koenig lookup including namespace std in 
cp_parser_perform_range_for_lookup. Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////
/cp
2013-12-10  Paolo Carlini  <paolo.carlini@oracle.com>

	Core DR 1442
	PR c++/59165
	* parser.c (cp_parser_perform_range_for_lookup): Don't pass true
	as include_std to perform_koenig_lookup.
	(cp_parser_postfix_expression): Adjust.
	* pt.c (tsubst_copy_and_build): Likewise.
	* semantics.c (perform_koenig_lookup): Remove bool parameter.
	(omp_reduction_lookup): Adjust.
	* name-lookup.c (lookup_arg_dependent_1): Remove bool parameter.
	(lookup_arg_dependent): Likewise.
	(lookup_function_nonclass): Adjust.
	* name-lookup.h: Adjust declaration.
	* cp-tree.h: Likewise.

/testsuite
2013-12-10  Paolo Carlini  <paolo.carlini@oracle.com>

	Core DR 1442
	PR c++/59165
	* g++.dg/cpp0x/range-for28.C: New.
	* g++.dg/cpp0x/range-for3.C: Update.

Comments

Paolo Carlini Dec. 23, 2013, 10:06 a.m. UTC | #1
Hi,

assuming I didn't miss anything (I'm still catching up with my emails), 
I'd like to ping the below. Thanks!

Paolo.

///////////////////////

On 12/10/2013 01:54 PM, Paolo Carlini wrote:
> Hi,
>
> as far as I can see, this bug asks for the implementation of 
> Core/1442, thus don't do a special Koenig lookup including namespace 
> std in cp_parser_perform_range_for_lookup. Tested x86_64-linux.
>
> Thanks,
> Paolo.
>
> /////////////////////////
Jason Merrill Jan. 2, 2014, 9:49 p.m. UTC | #2
OK.

Jason
diff mbox

Patch

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 205850)
+++ cp/cp-tree.h	(working copy)
@@ -5743,7 +5743,7 @@  extern tree finish_stmt_expr_expr		(tree, tree);
 extern tree finish_stmt_expr			(tree, bool);
 extern tree stmt_expr_value_expr		(tree);
 bool empty_expr_stmt_p				(tree);
-extern tree perform_koenig_lookup		(tree, vec<tree, va_gc> *, bool,
+extern tree perform_koenig_lookup		(tree, vec<tree, va_gc> *,
 						 tsubst_flags_t);
 extern tree finish_call_expr			(tree, vec<tree, va_gc> **, bool,
 						 bool, tsubst_flags_t);
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c	(revision 205850)
+++ cp/name-lookup.c	(working copy)
@@ -4879,7 +4879,7 @@  lookup_function_nonclass (tree name, vec<tree, va_
   return
     lookup_arg_dependent (name,
 			  lookup_name_real (name, 0, 1, block_p, 0, 0),
-			  args, false);
+			  args);
 }
 
 tree
@@ -5578,8 +5578,7 @@  arg_assoc (struct arg_lookup *k, tree n)
    are the functions found in normal lookup.  */
 
 static tree
-lookup_arg_dependent_1 (tree name, tree fns, vec<tree, va_gc> *args,
-			bool include_std)
+lookup_arg_dependent_1 (tree name, tree fns, vec<tree, va_gc> *args)
 {
   struct arg_lookup k;
 
@@ -5617,8 +5616,6 @@  static tree
   else
     k.fn_set = NULL;
 
-  if (include_std)
-    arg_assoc_namespace (&k, std_node);
   arg_assoc_args_vec (&k, args);
 
   fns = k.functions;
@@ -5643,13 +5640,12 @@  static tree
 /* Wrapper for lookup_arg_dependent_1.  */
 
 tree
-lookup_arg_dependent (tree name, tree fns, vec<tree, va_gc> *args,
-                      bool include_std)
+lookup_arg_dependent (tree name, tree fns, vec<tree, va_gc> *args)
 {
   tree ret;
   bool subtime;
   subtime = timevar_cond_start (TV_NAME_LOOKUP);
-  ret = lookup_arg_dependent_1 (name, fns, args, include_std);
+  ret = lookup_arg_dependent_1 (name, fns, args);
   timevar_cond_stop (TV_NAME_LOOKUP, subtime);
   return ret;
 }
Index: cp/name-lookup.h
===================================================================
--- cp/name-lookup.h	(revision 205850)
+++ cp/name-lookup.h	(working copy)
@@ -338,7 +338,7 @@  extern void do_toplevel_using_decl (tree, tree, tr
 extern void do_local_using_decl (tree, tree, tree);
 extern tree do_class_using_decl (tree, tree);
 extern void do_using_directive (tree);
-extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *, bool);
+extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *);
 extern bool is_associated_namespace (tree, tree);
 extern void parse_using_directive (tree, tree);
 extern tree innermost_non_namespace_value (tree);
Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 205850)
+++ cp/parser.c	(working copy)
@@ -6012,7 +6012,6 @@  cp_parser_postfix_expression (cp_parser *parser, b
 			if (!any_type_dependent_arguments_p (args))
 			  postfix_expression
 			    = perform_koenig_lookup (postfix_expression, args,
-						     /*include_std=*/false,
 						     complain);
 		      }
 		    else
@@ -6038,7 +6037,6 @@  cp_parser_postfix_expression (cp_parser *parser, b
 			if (!any_type_dependent_arguments_p (args))
 			  postfix_expression
 			    = perform_koenig_lookup (postfix_expression, args,
-						     /*include_std=*/false,
 						     complain);
 		      }
 		  }
@@ -10287,12 +10285,10 @@  cp_parser_perform_range_for_lookup (tree range, tr
 	  vec_safe_push (vec, range);
 
 	  member_begin = perform_koenig_lookup (id_begin, vec,
-						/*include_std=*/true,
 						tf_warning_or_error);
 	  *begin = finish_call_expr (member_begin, &vec, false, true,
 				     tf_warning_or_error);
 	  member_end = perform_koenig_lookup (id_end, vec,
-					      /*include_std=*/true,
 					      tf_warning_or_error);
 	  *end = finish_call_expr (member_end, &vec, false, true,
 				   tf_warning_or_error);
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 205850)
+++ cp/pt.c	(working copy)
@@ -14483,8 +14483,7 @@  tsubst_copy_and_build (tree t,
 	       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, false,
-					    tf_none);
+	  function = perform_koenig_lookup (function, call_args, tf_none);
 
 	if (identifier_p (function)
 	    && !any_type_dependent_arguments_p (call_args))
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 205850)
+++ cp/semantics.c	(working copy)
@@ -2041,12 +2041,10 @@  empty_expr_stmt_p (tree expr_stmt)
 
 /* Perform Koenig lookup.  FN is the postfix-expression representing
    the function (or functions) to call; ARGS are the arguments to the
-   call; if INCLUDE_STD then the `std' namespace is automatically
-   considered an associated namespace (used in range-based for loops).
-   Returns the functions to be considered by overload resolution.  */
+   call.  Returns the functions to be considered by overload resolution.  */
 
 tree
-perform_koenig_lookup (tree fn, vec<tree, va_gc> *args, bool include_std,
+perform_koenig_lookup (tree fn, vec<tree, va_gc> *args,
 		       tsubst_flags_t complain)
 {
   tree identifier = NULL_TREE;
@@ -2083,7 +2081,7 @@  tree
   if (!any_type_dependent_arguments_p (args)
       && !any_dependent_template_arguments_p (tmpl_args))
     {
-      fn = lookup_arg_dependent (identifier, functions, args, include_std);
+      fn = lookup_arg_dependent (identifier, functions, args);
       if (!fn)
 	{
 	  /* The unqualified name could not be resolved.  */
@@ -4643,7 +4641,7 @@  omp_reduction_lookup (location_t loc, tree id, tre
 	{
 	  vec<tree, va_gc> *args = NULL;
 	  vec_safe_push (args, build_reference_type (type));
-	  id = perform_koenig_lookup (id, args, false, tf_none);
+	  id = perform_koenig_lookup (id, args, tf_none);
 	}
     }
   else if (TREE_CODE (id) == SCOPE_REF)
Index: testsuite/g++.dg/cpp0x/range-for28.C
===================================================================
--- testsuite/g++.dg/cpp0x/range-for28.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/range-for28.C	(working copy)
@@ -0,0 +1,11 @@ 
+// PR c++/59165
+// { dg-require-effective-target c++11 }
+
+namespace std {
+int* begin(int i) { return (int*)0; }
+int* end(int i) { return (int*)0; }
+}
+
+int main() {
+  for (int a : 10) { }  // { dg-error "was not declared" }
+}
Index: testsuite/g++.dg/cpp0x/range-for3.C
===================================================================
--- testsuite/g++.dg/cpp0x/range-for3.C	(revision 205850)
+++ testsuite/g++.dg/cpp0x/range-for3.C	(working copy)
@@ -36,7 +36,7 @@  namespace std
 int main()
 {
     container c(1,4);
-    for (int it : c)
+    for (int it : c)    // { dg-error "was not declared" }
     {
     }
 }