diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-19 11:42:00 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-19 11:42:00 +0000 |
commit | 7e2ddf398b8d01a2f8a9a7fbca501f5a9880c100 (patch) | |
tree | 9204b258185a0624797fb4807dce1a65fe3ae908 /include | |
parent | 4adb982deb2759eb75b4611cdc067bba196d4498 (diff) | |
download | clang-7e2ddf398b8d01a2f8a9a7fbca501f5a9880c100.tar.gz clang-7e2ddf398b8d01a2f8a9a7fbca501f5a9880c100.tar.bz2 clang-7e2ddf398b8d01a2f8a9a7fbca501f5a9880c100.tar.xz |
[c++1z] Implement N3994: a range-based for loop can declare a variable with super-terse notation
for (x : range) { ... }
which is equivalent to
for (auto &&x : range) { ... }
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211267 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 7 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 7 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index b2da81e17d..874e0e2049 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -277,6 +277,13 @@ 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_cxx1y_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_expected_decl : Error< "for range declaration must declare a variable">; def err_argument_required_after_attribute : Error< diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 019660e184..2c76dce761 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1827,6 +1827,9 @@ private: return isDeclarationSpecifier(true); } + /// \brief Determine whether this is a C++1z for-range-identifier. + bool isForRangeIdentifier(); + /// \brief Determine whether we are currently at the start of an Objective-C /// class message that appears to be missing the open bracket '['. bool isStartOfObjCClassMessageMissingOpenBracket(); @@ -2006,6 +2009,10 @@ private: // for example, attributes appertain to decl specifiers. void ProhibitCXX11Attributes(ParsedAttributesWithRange &attrs); + /// \brief Skip C++11 attributes and return the end location of the last one. + /// \returns SourceLocation() if there are no attributes. + SourceLocation SkipCXX11Attributes(); + /// \brief Diagnose and skip C++11 attributes that appear in syntactic /// locations where attributes are not allowed. void DiagnoseAndSkipCXX11Attributes(); diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 86ab905dbb..872dbffb80 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1622,6 +1622,10 @@ public: void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto); void ActOnInitializerError(Decl *Dcl); void ActOnCXXForRangeDecl(Decl *D); + StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, + IdentifierInfo *Ident, + ParsedAttributes &Attrs, + SourceLocation AttrEnd); void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc); void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc); void FinalizeDeclaration(Decl *D); |