public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Implement P0962
@ 2018-03-22  1:20 Ville Voutilainen
  2018-03-22 18:24 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Ville Voutilainen @ 2018-03-22  1:20 UTC (permalink / raw)
  To: gcc-patches, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]

Tested on Linux-PPC64.

2018-03-22  Ville Voutilainen  <ville.voutilainen@gmail.com>

    gcc/cp/

    Implement P0962
    * parser.c (cp_parser_perform_range_for_lookup): Change
    the condition for deciding whether to use members.

    testsuite/

    Implement P0962
   * g++.dg/cpp0x/range-for13.C: Adjust.

[-- Attachment #2: P0962.diff --]
[-- Type: text/x-patch, Size: 2179 bytes --]

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4e3e1dc..ed3c085 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12046,7 +12046,7 @@ cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end)
 				  /*protect=*/2, /*want_type=*/false,
 				  tf_warning_or_error);
 
-      if (member_begin != NULL_TREE || member_end != NULL_TREE)
+      if (member_begin != NULL_TREE && member_end != NULL_TREE)
 	{
 	  /* Use the member functions.  */
 	  if (member_begin != NULL_TREE)
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for13.C b/gcc/testsuite/g++.dg/cpp0x/range-for13.C
index 9ed0458..7babd71 100644
--- a/gcc/testsuite/g++.dg/cpp0x/range-for13.C
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for13.C
@@ -3,18 +3,6 @@
 
 // { dg-do compile { target c++11 } }
 
-//These should not be used
-template<typename T> int *begin(T &t)
-{
-    T::fail;
-    return 0;
-}
-template<typename T> int *end(T &t)
-{
-    T::fail;
-    return 0;
-}
-
 struct container1
 {
     int *begin();
@@ -89,10 +77,37 @@ struct container10
     static function end;
 };
 
+namespace N
+{
+template<typename T> int *begin(T &t)
+{
+    return 0;
+}
+template<typename T> int *end(T &t)
+{
+    return 0;
+}
+struct container11
+{
+    int *begin();
+    //no end
+};
+
+struct container12
+{
+    int *end();
+    //no begin
+};
+
+struct container13
+{
+};
+}
+
 void test1()
 {
-  for (int x : container1()); // { dg-error "member but not" }
-  for (int x : container2()); // { dg-error "member but not" }
+  for (int x : container1()); // { dg-error "'begin' was not declared|'end' was not declared" }
+  for (int x : container2()); // { dg-error "'begin' was not declared|'end' was not declared" }
   for (int x : container3()); // { dg-error "within this context" }
   for (int x : container4()); // { dg-error "cannot be used as a function" }
   for (int x : container5()); // { dg-error "invalid use of" }
@@ -101,4 +116,7 @@ void test1()
   for (int x : container8());
   for (int x : container9()); // { dg-error "within this context" }
   for (int x : container10());
+  for (int x : N::container11());
+  for (int x : N::container12());
+  for (int x : N::container13());
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Implement P0962
  2018-03-22  1:20 [C++ PATCH] Implement P0962 Ville Voutilainen
@ 2018-03-22 18:24 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-03-22 18:24 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: gcc-patches List

OK, thanks.

On Wed, Mar 21, 2018 at 8:42 PM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> Tested on Linux-PPC64.
>
> 2018-03-22  Ville Voutilainen  <ville.voutilainen@gmail.com>
>
>     gcc/cp/
>
>     Implement P0962
>     * parser.c (cp_parser_perform_range_for_lookup): Change
>     the condition for deciding whether to use members.
>
>     testsuite/
>
>     Implement P0962
>    * g++.dg/cpp0x/range-for13.C: Adjust.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-22 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22  1:20 [C++ PATCH] Implement P0962 Ville Voutilainen
2018-03-22 18:24 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).