From a379fcb01c6a0a0be996e0fe156de107d70e9927 Mon Sep 17 00:00:00 2001
From: Richard Smith
Date: Thu, 27 Nov 2014 01:54:27 +0000
Subject: [PATCH] [c++1z] Remove terse range-based for loops; they've been
removed from consideration for C++17 for now. Update C++ status page to
match.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222865 91177308-0d34-0410-b5e6-96231b3b80d8
---
include/clang/Basic/DiagnosticParseKinds.td | 9 ++-------
lib/Parse/ParseStmt.cpp | 4 +---
test/SemaCXX/for-range-examples.cpp | 20 +++++++++++---------
www/cxx_status.html | 15 ++++++++++-----
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index 7a9d8dd56d..759bcda10e 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -290,13 +290,8 @@ def ext_for_range : ExtWarn<
def warn_cxx98_compat_for_range : Warning<
"range-based for loop is incompatible with C++98">,
InGroup, DefaultIgnore;
-def ext_for_range_identifier : ExtWarn<
- "range-based for loop with implicit deduced type is a C++1z extension">,
- InGroup;
-def warn_cxx14_compat_for_range_identifier : Warning<
- "range-based for loop with implicit deduced type is incompatible with "
- "C++ standards before C++1z">,
- InGroup, DefaultIgnore;
+def err_for_range_identifier : Error<
+ "range-based for loop requires type for loop variable">;
def err_for_range_expected_decl : Error<
"for range declaration must declare a variable">;
def err_argument_required_after_attribute : Error<
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 1bfce60a3b..752baf663b 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1520,9 +1520,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
else
ForRangeInit.RangeExpr = ParseExpression();
- Diag(Loc, getLangOpts().CPlusPlus1z
- ? diag::warn_cxx14_compat_for_range_identifier
- : diag::ext_for_range_identifier)
+ Diag(Loc, diag::err_for_range_identifier)
<< ((getLangOpts().CPlusPlus11 && !getLangOpts().CPlusPlus1z)
? FixItHint::CreateInsertion(Loc, "auto &&")
: FixItHint());
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp
index 2f777fb46d..d07331c51e 100644
--- a/test/SemaCXX/for-range-examples.cpp
+++ b/test/SemaCXX/for-range-examples.cpp
@@ -214,17 +214,19 @@ namespace test6 {
namespace test7 {
void f() {
int arr[5], b;
- for (a : arr) {} // expected-warning {{extension}}
- // FIXME: Give a -Wshadow for this by default?
- for (b : arr) {} // expected-warning {{extension}}
- for (arr : arr) {} // expected-warning {{extension}}
- for (c alignas(8) : arr) { // expected-warning {{extension}}
+ for (a : arr) {} // expected-error {{requires type for loop variable}}
+ // FIXME: Give a different error in this case?
+ for (b : arr) {} // expected-error {{requires type for loop variable}}
+ for (arr : arr) {} // expected-error {{requires type for loop variable}}
+ for (c alignas(8) : arr) { // expected-error {{requires type for loop variable}}
static_assert(alignof(c) == 8, ""); // expected-warning {{extension}}
}
- // FIXME: We should reject this, but don't, because we only check the
- // attribute before we deduce the 'auto' type.
- for (d alignas(1) : arr) {} // expected-warning {{extension}}
- for (e [[deprecated]] : arr) { e = 0; } // expected-warning {{deprecated}} expected-note {{here}} expected-warning {{extension}}
+ // FIXME: The fix-it hint here is not sufficient to fix the error.
+ // We fail to diagnose that d is underaligned for its type, because
+ // we check the alignment attribute before we perform the auto
+ // deduction.
+ for (d alignas(1) : arr) {} // expected-error {{requires type for loop variable}}
+ for (e [[deprecated]] : arr) { e = 0; } // expected-warning {{deprecated}} expected-note {{here}} expected-error {{requires type for loop variable}}
}
}
diff --git a/www/cxx_status.html b/www/cxx_status.html
index 7b6fac0078..41c827eb84 100644
--- a/www/cxx_status.html
+++ b/www/cxx_status.html
@@ -536,11 +536,16 @@ as the draft C++1z standard evolves.
N4086 |
Clang 3.5 |
+
typename in a template template parameter |
N4051 |
@@ -549,7 +554,7 @@ as the draft C++1z standard evolves.
New auto rules for direct-list-initialization
| N3922 |
- No |
+ No |
@@ -600,7 +605,7 @@ Clang version they became available:
-
+ |
SVN (N4200)
|
--
2.40.0