diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-11-27 01:54:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-11-27 01:54:27 +0000 |
commit | 83d3f150c86a7fe86ebabc44f34ceca0979725cb (patch) | |
tree | c6af680efd6067842dfbc88e871884b0e1450660 | |
parent | 7ea98e142b9c3ce361739816eece77470bf00248 (diff) | |
download | bcm5719-llvm-83d3f150c86a7fe86ebabc44f34ceca0979725cb.tar.gz bcm5719-llvm-83d3f150c86a7fe86ebabc44f34ceca0979725cb.zip |
[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.
llvm-svn: 222865
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 9 | ||||
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/for-range-examples.cpp | 20 | ||||
-rw-r--r-- | clang/www/cxx_status.html | 15 |
4 files changed, 24 insertions, 24 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 7a9d8dd56d4..759bcda10ec 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/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<CXX98Compat>, DefaultIgnore; -def ext_for_range_identifier : ExtWarn< - "range-based for loop with implicit deduced type is a C++1z extension">, - InGroup<CXX1z>; -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<CXXPre1zCompat>, 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/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 1bfce60a3bf..752baf663bb 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/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/clang/test/SemaCXX/for-range-examples.cpp b/clang/test/SemaCXX/for-range-examples.cpp index 2f777fb46df..d07331c51e2 100644 --- a/clang/test/SemaCXX/for-range-examples.cpp +++ b/clang/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/clang/www/cxx_status.html b/clang/www/cxx_status.html index 7b6fac00781..41c827eb841 100644 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -536,11 +536,16 @@ as the draft C++1z standard evolves.</p> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4086.html">N4086</a></td> <td class="full" align="center">Clang 3.5</td> </tr> + <!-- <tr> - <td>Terse range-based for loops</td> - <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3994.htm">N3994</a></td> - <td class="full" align="center">Clang 3.5</td> + <td rowspan="2">Terse range-based for loops (removed from C++1z)</td> + <td rowspan="2"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3994.htm">N3994</a></td> + <td class="none" align="center">Clang 3.5: Yes</td> + </tr> + <tr> + <td class="svn" align="center">SVN: No</td> </tr> + --> <tr> <td><tt>typename</tt> in a template template parameter</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4051.html">N4051</a></td> @@ -549,7 +554,7 @@ as the draft C++1z standard evolves.</p> <tr> <td>New <tt>auto</tt> rules for direct-list-initialization <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3922.html">N3922</a></td> - <td class="no" align="center">No</td> + <td class="none" align="center">No</td> </tr> <!-- Urbana papers --> <tr> @@ -600,7 +605,7 @@ Clang version they became available:</p> </td> </tr> <tr> - <td class="full" align="center"> + <td class="svn" align="center"> SVN (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4200">N4200</a>)</a> </td> </tr> |