diff options
author | Faisal Vali <faisalv@yahoo.com> | 2018-04-25 02:42:26 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2018-04-25 02:42:26 +0000 |
commit | 936de9d666009ddce7bedc5b073bc06c860d5f5b (patch) | |
tree | 440e812f02457e38b03ebed89c36ecfc22a052a3 /clang/lib/Parse/ParseDecl.cpp | |
parent | e21278d93805689c5e5d6bb1d52a8d907fd7ba5c (diff) | |
download | llvm-936de9d666009ddce7bedc5b073bc06c860d5f5b.zip llvm-936de9d666009ddce7bedc5b073bc06c860d5f5b.tar.gz llvm-936de9d666009ddce7bedc5b073bc06c860d5f5b.tar.bz2 |
[c++2a] [concepts] Add rudimentary parsing support for template concept declarations
This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly.
See the test file to get a sense of the basic parsing that this patch supports.
There is much more work to be done before concepts are usable...
Thanks Changyu!
llvm-svn: 330794
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 3d3abe3..9b0828a 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1739,7 +1739,8 @@ Parser::ParseSimpleDeclaration(DeclaratorContext Context, ParsingDeclSpec DS(*this); DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context); - ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none, DSContext); + ParseDeclarationSpecifiersOrConceptDefinition(DS, ParsedTemplateInfo(), + AS_none, DSContext); // If we had a free-standing type definition with a missing semicolon, we // may get this far before the problem becomes obvious. @@ -2386,7 +2387,8 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS, AccessSpecifier AS, /// specifier-qualifier-list is a subset of declaration-specifiers. Just /// parse declaration-specifiers and complain about extra stuff. /// TODO: diagnose attribute-specifiers and alignment-specifiers. - ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC); + ParseDeclarationSpecifiersOrConceptDefinition(DS, ParsedTemplateInfo(), AS, + DSC); // Validate declspec for type-name. unsigned Specs = DS.getParsedSpecifiers(); @@ -2871,11 +2873,12 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS, // and call ParsedFreeStandingDeclSpec as appropriate. DS.ClearTypeSpecType(); ParsedTemplateInfo NotATemplate; - ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs); + ParseDeclarationSpecifiersOrConceptDefinition(DS, NotATemplate, AS, DSContext, + LateAttrs); return false; } -/// ParseDeclarationSpecifiers +/// ParseDeclarationSpecifiersOrConceptDefinition /// declaration-specifiers: [C99 6.7] /// storage-class-specifier declaration-specifiers[opt] /// type-specifier declaration-specifiers[opt] @@ -2902,7 +2905,8 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS, /// [OpenCL] '__kernel' /// 'friend': [C++ dcl.friend] /// 'constexpr': [C++0x dcl.constexpr] -void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, +/// [C++2a] 'concept' +void Parser::ParseDeclarationSpecifiersOrConceptDefinition(DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, DeclSpecContext DSContext, @@ -3680,7 +3684,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, ConsumeToken(); ParseEnumSpecifier(Loc, DS, TemplateInfo, AS, DSContext); continue; - + + case tok::kw_concept: + ConsumeToken(); + ParseConceptDefinition(Loc, DS, TemplateInfo, AS, DSContext); + continue; // cv-qualifier: case tok::kw_const: isInvalid = DS.SetTypeQual(DeclSpec::TQ_const, Loc, PrevSpec, DiagID, @@ -6366,7 +6374,7 @@ void Parser::ParseParameterDeclarationClause( // too much hassle. DS.takeAttributesFrom(FirstArgAttrs); - ParseDeclarationSpecifiers(DS); + ParseDeclarationSpecifiersOrConceptDefinition(DS); // Parse the declarator. This is "PrototypeContext" or |