* parser.c (cp_parser_for_init_statement): Change range-for error
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jun 2014 18:15:42 +0000 (18:15 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jun 2014 18:15:42 +0000 (18:15 +0000)
to pedwarn.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212044 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp0x/range-for9.C

index 669e714..6fbd27a 100644 (file)
@@ -1,5 +1,8 @@
 2014-06-26  Jason Merrill  <jason@redhat.com>
 
+       * parser.c (cp_parser_for_init_statement): Change range-for error
+       to pedwarn.
+
        N3994 Ranged-based for-loops: The Next Generation
        * parser.c (cp_lexer_nth_token_is): New.
        (cp_parser_for_init_statement): Allow "for (id : init)".
index 426dca4..a7edd41 100644 (file)
@@ -10647,9 +10647,9 @@ cp_parser_for_init_statement (cp_parser* parser, tree *decl)
          is_range_for = true;
          if (cxx_dialect < cxx11)
            {
-             error_at (cp_lexer_peek_token (parser->lexer)->location,
-                       "range-based %<for%> loops are not allowed "
-                       "in C++98 mode");
+             pedwarn (cp_lexer_peek_token (parser->lexer)->location, 0,
+                      "range-based %<for%> loops only available with "
+                      "-std=c++11 or -std=gnu++11");
              *decl = error_mark_node;
            }
        }
index c51cbf9..6a50ec3 100644 (file)
@@ -1,7 +1,6 @@
 // Test for range-based for loop error in C++98 mode
 
-// { dg-do compile }
-// { dg-options "-std=c++98" }
+// { dg-do compile { target { ! c++11 } } }
 
 void test()
 {