diff options
author | Faisal Vali <faisalv@yahoo.com> | 2018-04-26 00:42:40 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2018-04-26 00:42:40 +0000 |
commit | 9626b8d4ee5c7c80e6c3962f224fbe12689de975 (patch) | |
tree | 159a319da26a2eaa957679ed371de73c5b777cca /lib | |
parent | c022c7bd3790932b0ddd3d139d484c3b0d5cb554 (diff) | |
download | clang-9626b8d4ee5c7c80e6c3962f224fbe12689de975.tar.gz |
Revert rC330794 and some dependent tiny bug fixes
See Richard's humbling feedback here:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html
Wish I'd had the patience to solicit the feedback prior to committing :)
Sorry for the noise guys.
Thank you Richard for being the steward that clang deserves!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTDumper.cpp | 7 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 1 | ||||
-rw-r--r-- | lib/AST/DeclTemplate.cpp | 21 | ||||
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 1 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 1 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 22 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 170 | ||||
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 1 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 66 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 76 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 | ||||
-rw-r--r-- | lib/Serialization/ASTCommon.cpp | 1 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 9 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 1 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 7 |
20 files changed, 29 insertions, 382 deletions
diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index b0f0c5d0f5..cf512b9bd3 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -466,7 +466,6 @@ namespace { bool DumpRefOnly); template<typename TemplateDecl> void VisitTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst); - void VisitConceptDecl(const ConceptDecl *D); void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D); void VisitClassTemplateDecl(const ClassTemplateDecl *D); void VisitClassTemplateSpecializationDecl( @@ -1578,12 +1577,6 @@ void ASTDumper::VisitTemplateDecl(const TemplateDecl *D, !D->isCanonicalDecl()); } -void ASTDumper::VisitConceptDecl(const ConceptDecl *D) { - dumpName(D); - dumpTemplateParameters(D->getTemplateParameters()); - dumpStmt(D->getConstraintExpr()); -} - void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) { // FIXME: We don't add a declaration of a function template specialization // to its context when it's explicitly instantiated, so dump explicit diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index ba02903683..baf83a393c 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -724,7 +724,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case Binding: case NonTypeTemplateParm: case VarTemplate: - case Concept: // These (C++-only) declarations are found by redeclaration lookup for // tag types, so we include them in the tag namespace. return IDNS_Ordinary | IDNS_Tag; diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index 19778af79f..8854f7879a 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -789,27 +789,6 @@ ClassTemplateSpecializationDecl::getSourceRange() const { } //===----------------------------------------------------------------------===// -// ConceptDecl Implementation -//===----------------------------------------------------------------------===// -ConceptDecl *ConceptDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation NameLoc, DeclarationName Name, - TemplateParameterList *Params, - Expr *ConstraintExpr) { - // TODO: Do we need this? - // AdoptTemplateParameterList(Params, cast<DeclContext>(Decl)); - return new (C, DC) ConceptDecl(DC, NameLoc, Name, Params, ConstraintExpr); -} - -ConceptDecl *ConceptDecl::CreateDeserialized(ASTContext &C, - unsigned ID) { - ConceptDecl *Result = new (C, ID) ConceptDecl(nullptr, SourceLocation(), - DeclarationName(), - nullptr, nullptr); - - return Result; -} - -//===----------------------------------------------------------------------===// // ClassTemplatePartialSpecializationDecl Implementation //===----------------------------------------------------------------------===// void ClassTemplatePartialSpecializationDecl::anchor() {} diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 38eb0c8fe7..c9b80e38d4 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -105,7 +105,6 @@ void CodeGenFunction::EmitDecl(const Decl &D) { case Decl::OMPThreadPrivate: case Decl::OMPCapturedExpr: case Decl::Empty: - case Decl::Concept: // None of these decls require codegen support. return; diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index b8bed33b02..063b9be4cd 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -4423,7 +4423,6 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { case Decl::TypeAliasTemplate: case Decl::Block: case Decl::Empty: - case Decl::Concept: break; case Decl::Using: // using X; [C++] if (CGDebugInfo *DI = getModuleDebugInfo()) diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 9b0828a6d5..3d3abe32ab 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1739,8 +1739,7 @@ Parser::ParseSimpleDeclaration(DeclaratorContext Context, ParsingDeclSpec DS(*this); DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context); - ParseDeclarationSpecifiersOrConceptDefinition(DS, ParsedTemplateInfo(), - AS_none, DSContext); + ParseDeclarationSpecifiers(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. @@ -2387,8 +2386,7 @@ 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. - ParseDeclarationSpecifiersOrConceptDefinition(DS, ParsedTemplateInfo(), AS, - DSC); + ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC); // Validate declspec for type-name. unsigned Specs = DS.getParsedSpecifiers(); @@ -2873,12 +2871,11 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS, // and call ParsedFreeStandingDeclSpec as appropriate. DS.ClearTypeSpecType(); ParsedTemplateInfo NotATemplate; - ParseDeclarationSpecifiersOrConceptDefinition(DS, NotATemplate, AS, DSContext, - LateAttrs); + ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs); return false; } -/// ParseDeclarationSpecifiersOrConceptDefinition +/// ParseDeclarationSpecifiers /// declaration-specifiers: [C99 6.7] /// storage-class-specifier declaration-specifiers[opt] /// type-specifier declaration-specifiers[opt] @@ -2905,8 +2902,7 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS, /// [OpenCL] '__kernel' /// 'friend': [C++ dcl.friend] /// 'constexpr': [C++0x dcl.constexpr] -/// [C++2a] 'concept' -void Parser::ParseDeclarationSpecifiersOrConceptDefinition(DeclSpec &DS, +void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, DeclSpecContext DSContext, @@ -3684,11 +3680,7 @@ void Parser::ParseDeclarationSpecifiersOrConceptDefinition(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, @@ -6374,7 +6366,7 @@ void Parser::ParseParameterDeclarationClause( // too much hassle. DS.takeAttributesFrom(FirstArgAttrs); - ParseDeclarationSpecifiersOrConceptDefinition(DS); + ParseDeclarationSpecifiers(DS); // Parse the declarator. This is "PrototypeContext" or diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index e0db75ced5..0c789c9b1c 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2561,8 +2561,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, if (MalformedTypeSpec) DS.SetTypeSpecError(); - ParseDeclarationSpecifiersOrConceptDefinition( - DS, TemplateInfo, AS, DeclSpecContext::DSC_class, &CommonLateParsedAttrs); + ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class, + &CommonLateParsedAttrs); // Turn off colon protection that was set for declspec. X.restore(); diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 203d5e6d0d..0ac418ad70 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1490,7 +1490,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, cStyleParamWarned = true; } DeclSpec DS(AttrFactory); - ParseDeclarationSpecifiersOrConceptDefinition(DS); + ParseDeclarationSpecifiers(DS); // Parse the declarator. Declarator ParmDecl(DS, DeclaratorContext::PrototypeContext); ParseDeclarator(ParmDecl); @@ -2541,7 +2541,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { Scope::AtCatchScope); if (Tok.isNot(tok::ellipsis)) { DeclSpec DS(AttrFactory); - ParseDeclarationSpecifiersOrConceptDefinition(DS); + ParseDeclarationSpecifiers(DS); Declarator ParmDecl(DS, DeclaratorContext::ObjCCatchContext); ParseDeclarator(ParmDecl); diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 13fb6da3c3..88a5745350 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -54,15 +54,6 @@ Parser::ParseDeclarationStartingWithTemplate(DeclaratorContext Context, /// template-declaration: [C++ temp] /// 'export'[opt] 'template' '<' template-parameter-list '>' declaration /// -/// template-declaration: [C++2a] -/// template-head declaration -/// template-head concept-definition -/// -/// TODO: requires-clause -/// template-head: [C++2a] -/// 'export'[opt] 'template' '<' template-parameter-list '>' -/// requires-clause[opt] -/// /// explicit-specialization: [ C++ temp.expl.spec] /// 'template' '<' '>' declaration Decl * @@ -157,10 +148,13 @@ Parser::ParseTemplateDeclarationOrSpecialization(DeclaratorContext Context, unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope; ParseScopeFlags TemplateScopeFlags(this, NewFlags, isSpecialization); - return ParseSingleDeclarationAfterTemplate( - Context, - ParsedTemplateInfo(&ParamLists, isSpecialization, LastParamListWasEmpty), - ParsingTemplateParams, DeclEnd, AS, AccessAttrs); + // Parse the actual template declaration. + return ParseSingleDeclarationAfterTemplate(Context, + ParsedTemplateInfo(&ParamLists, + isSpecialization, + LastParamListWasEmpty), + ParsingTemplateParams, + DeclEnd, AS, AccessAttrs); } /// \brief Parse a single declaration that declares a template, @@ -214,7 +208,7 @@ Parser::ParseSingleDeclarationAfterTemplate( // the template parameters. ParsingDeclSpec DS(*this, &DiagsFromTParams); - ParseDeclarationSpecifiersOrConceptDefinition(DS, TemplateInfo, AS, + ParseDeclarationSpecifiers(DS, TemplateInfo, AS, getDeclSpecContextFromDeclaratorContext(Context)); if (Tok.is(tok::semi)) { @@ -328,150 +322,6 @@ Parser::ParseSingleDeclarationAfterTemplate( return ThisDecl; } - -void -Parser::ParseConceptDefinition(SourceLocation ConceptLoc,
- DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo,
- AccessSpecifier AS,
- DeclSpecContext DSC) { -
-
- auto DiagnoseAttributes = [this] {
- ParsedAttributesWithRange attrs(this->AttrFactory);
- this->MaybeParseGNUAttributes(attrs);
- this->MaybeParseCXX11Attributes(attrs);
- this->MaybeParseMicrosoftDeclSpecs(attrs); - this->ProhibitAttributes(attrs); - }; - - - // If attributes exist after 'concept' kw but before the concept name, - // prohibit them for now (if CWG approves attributes on concepts, this is - // likely where they will go...). - DiagnoseAttributes(); - - // Set the concept specifier at ConceptLoc within 'DS' along with emitting any - // incompatible decl-specifier diagnostics. - { - const char *PrevSpec = 0; - unsigned int DiagId = 0; - if (DS.setConceptSpec(ConceptLoc, PrevSpec, DiagId, - Actions.getASTContext().getPrintingPolicy())) { - Diag(ConceptLoc, DiagId) << PrevSpec; - } - Actions.DiagnoseFunctionSpecifiers(DS); - } - - if (DSC != DeclSpecContext::DSC_top_level) { - Diag(ConceptLoc, diag::err_concept_at_non_namespace_scope); - // If we are not in a template parameter context, skip to a '}' or ';'. The - // error messages are better if we just ignore this within template - // parameter lists. - if (DSC != DeclSpecContext::DSC_template_param) { - SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch); - } else { - tok::TokenKind Tokens[] = { tok::comma, tok::greater }; - SkipUntil(llvm::makeArrayRef(Tokens), - StopAtSemi | StopBeforeMatch); - } - return; - } - - // A scope-guard that (if an error occurs while parsing a concept) skips to - // the next semi or closing brace. - class SkipUntilSemiOrClosingBraceOnScopeExit { - Parser &P; - bool Disabled = false; - - public: - SkipUntilSemiOrClosingBraceOnScopeExit(Parser &P) - : P(P) {} - void disable() { Disabled = true; } - ~SkipUntilSemiOrClosingBraceOnScopeExit() { - if (!Disabled) { - // Skip until the semi-colon or a '}'. - P.SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch); - } - } - } SkipUntilSemiOrClosingBraceOnScopeExit(*this); - - if (TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate) { - Diag(ConceptLoc, diag::err_concept_nontemplate); - return; - } - - const TemplateParameterLists &ParamLists = *TemplateInfo.TemplateParams; - - - // More than one TPL wouldn't make sense here. - if (ParamLists.size() != 1) { - Diag(Tok.getLocation(), diag::err_concept_extra_headers); - return; - } - const TemplateParameterList *const TPL = ParamLists[0]; - - // Explicit specializations of concepts are not allowed. - if (TPL->getLAngleLoc().getLocWithOffset(1) == TPL->getRAngleLoc()) { - assert(!TPL->size() && - "can not have template parameters within empty angle brackets!"); - Diag(ConceptLoc, diag::err_concept_specialized) << 0; - return; - } - // Concepts can not be defined with nested name specifiers. - CXXScopeSpec SS; - if (ParseOptionalCXXScopeSpecifier(SS, nullptr, - /*EnteringContext=*/false) || - SS.isNotEmpty()) { - - if (SS.isNotEmpty()) - Diag(Tok.getLocation(), diag::err_concept_unexpected_scope_spec); - return; - } - // An identifier (i.e. the concept-name) should follow 'concept'. - if (!Tok.is(tok::identifier)) { - Diag(Tok.getLocation(), diag::err_expected) << "concept name"; - return; - } - - IdentifierInfo *Id = Tok.getIdentifierInfo(); - SourceLocation IdLoc = ConsumeToken(); - - // If attributes exist after the identifier, parse them and diagnose - DiagnoseAttributes(); - - if (!TryConsumeToken(tok::equal)) { - Diag(Tok.getLocation(), diag::err_expected) << "equal"; - return; - } - - ExprResult ConstraintExprResult = ParseConstraintExpression(); - if (ConstraintExprResult.isInvalid()) { - Diag(Tok.getLocation(), diag::err_expected_expression) - << "constraint-expression"; - return; - } - - // We can try to create a valid concept decl node now, so disable the - // scope-guard. - SkipUntilSemiOrClosingBraceOnScopeExit.disable(); - - Expr *ConstraintExpr = ConstraintExprResult.get(); - ConceptDecl *const ConDecl = Actions.ActOnConceptDefinition( - getCurScope(), *TemplateInfo.TemplateParams, Id, IdLoc, ConstraintExpr); - DS.setConceptRep(ConDecl); - - if (Tok.isNot(tok::semi)) { - - ExpectAndConsume(tok::semi, diag::err_expected_after, "concept"); - // Push this token back into the preprocessor and change our current token - // to ';' so that the rest of the code recovers as though there were an - // ';' after the definition. - PP.EnterToken(Tok); - Tok.setKind(tok::semi); - } - return; -} - /// ParseTemplateParameters - Parses a template-parameter-list enclosed in /// angle brackets. Depth is the depth of this template-parameter-list, which /// is the number of template headers directly enclosing this template header. @@ -840,8 +690,8 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { // FIXME: The type should probably be restricted in some way... Not all // declarators (parts of declarators?) are accepted for parameters. DeclSpec DS(AttrFactory); - ParseDeclarationSpecifiersOrConceptDefinition( - DS, ParsedTemplateInfo(), AS_none, DeclSpecContext::DSC_template_param); + ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none, + DeclSpecContext::DSC_template_param); // Parse this as a typename. Declarator ParamDecl(DS, DeclaratorContext::TemplateParamContext); diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 5648d994fc..ebd6f0f5b8 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -1351,7 +1351,6 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, case tok::kw_struct: case tok::kw_union: case tok::kw___interface: - case tok::kw_concept: // enum-specifier case tok::kw_enum: // cv-qualifier diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 17d046958d..d8f9f7a390 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -919,7 +919,7 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, AccessSpecifier AS) { MaybeParseMicrosoftAttributes(DS.getAttributes()); // Parse the common declaration-specifiers piece. - ParseDeclarationSpecifiersOrConceptDefinition(DS, ParsedTemplateInfo(), AS, + ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DeclSpecContext::DSC_top_level); // If we had a free-standing type definition with a missing semicolon, we @@ -1287,7 +1287,7 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // Parse the common declaration-specifiers piece. DeclSpec DS(AttrFactory); - ParseDeclarationSpecifiersOrConceptDefinition(DS); + ParseDeclarationSpecifiers(DS); // C99 6.9.1p6: 'each declaration in the declaration list shall have at // least one declarator'. @@ -1647,7 +1647,7 @@ bool Parser::TryKeywordIdentFallback(bool DisableKeyword) { /// Actions.getTypeName will not be needed to be called again (e.g. getTypeName /// will not be called twice, once to check whether we have a declaration /// specifier, and another one to get the actual type inside -/// ParseDeclarationSpecifiersOrConceptDefinition). +/// ParseDeclarationSpecifiers). /// /// This returns true if an error occurred. /// diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 5f5d94eee3..2fad5a18ba 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -426,7 +426,6 @@ unsigned DeclSpec::getParsedSpecifiers() const { return Res; } - template <class T> static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, unsigned &DiagID, @@ -492,6 +491,7 @@ const char *DeclSpec::getSpecifierName(TSS S) { } llvm_unreachable("Unknown typespec!"); } + const char *DeclSpec::getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy) { switch (T) { @@ -969,69 +969,6 @@ bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, return false; } -bool DeclSpec::setConceptSpec(const SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID, const PrintingPolicy &PP) { - assert(Loc.isValid() && "Loc must be valid, since it is used to identify " - "that this function was called before"); - assert(!ConceptLoc.isValid() && - "how is this called if concept was already encountered and triggered " - "ParseConceptDefinition which parses upto the semi-colon"); - - PrevSpec = nullptr; - if (TypeSpecType != TST_unspecified) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<TST>(TypeSpecType), PP); - ClearTypeSpecType(); - } - if (TypeSpecSign != TSS_unspecified) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<TSS>(TypeSpecSign)); - TypeSpecSign = TSS_unspecified; - } - if (TypeSpecWidth != TSW_unspecified) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<TSW>(TypeSpecWidth)); - TypeSpecWidth = TSW_unspecified; - } - if (StorageClassSpec != SCS_unspecified) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<SCS>(StorageClassSpec)); - ClearStorageClassSpecs(); - } - if (ThreadStorageClassSpec != TSCS_unspecified) { - PrevSpec = - DeclSpec::getSpecifierName(static_cast<TSCS>(ThreadStorageClassSpec)); - ClearStorageClassSpecs(); - } - if (TypeSpecComplex != TSC_unspecified) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<TSC>(TypeSpecComplex)); - TypeSpecComplex = TSC_unspecified; - } - if (getTypeQualifiers()) { - PrevSpec = DeclSpec::getSpecifierName(static_cast<TQ>(TypeQualifiers)); - ClearTypeQualifiers(); - } - if (isFriendSpecified()) { - PrevSpec = "friend"; - Friend_specified = false; - FriendLoc = SourceLocation(); - } - if (isConstexprSpecified()) { - PrevSpec = "constexpr"; - Constexpr_specified = false; - ConstexprLoc = SourceLocation(); - } - if (isInlineSpecified()) { - PrevSpec = "inline"; - FS_inlineLoc = SourceLocation(); - FS_inline_specified = false; - } - - if (PrevSpec) { - DiagID = diag::err_invalid_decl_spec_combination; - } - // We set the concept location regardless of whether an error occurred. - DeclRep = nullptr; - ConceptLoc = Loc; - return PrevSpec; // If this is non-null, an error occurred. -} - void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.Sign = getTypeSpecSign(); writtenBS.Width = getTypeSpecWidth(); @@ -1333,7 +1270,6 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { // TODO: return "auto function" and other bad things based on the real type. // 'data definition has no type or storage class'? - } bool DeclSpec::isMissingDeclaratorOk() { diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index acbec1aca9..1bcc9329e4 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4212,12 +4212,6 @@ Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, MultiTemplateParamsArg TemplateParams, bool IsExplicitInstantiation, RecordDecl *&AnonRecord) { - - // We don't need to do any additional declspecifier checking on concept - // definitions since that should already have been done when the concept kw - // location was set within DS. - if (DS.isConceptSpecified()) return DS.getRepAsConcept(); - Decl *TagD = nullptr; TagDecl *Tag = nullptr; if (DS.getTypeSpecType() == DeclSpec::TST_class || diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 0fc399a375..678f6af068 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -9467,7 +9467,7 @@ UsingShadowDecl *Sema::BuildUsingShadowDecl(Scope *S, NonTemplateTarget = TargetTD->getTemplatedDecl(); UsingShadowDecl *Shadow; - if (!isa<ConceptDecl>(Target) && isa<CXXConstructorDecl>(NonTemplateTarget)) { + if (isa<CXXConstructorDecl>(NonTemplateTarget)) { bool IsVirtualBase = isVirtualDirectBase(cast<CXXRecordDecl>(CurContext), UD->getQualifier()->getAsRecordDecl()); diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index f3cb04ac6a..190dd0721f 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -232,11 +232,9 @@ TemplateNameKind Sema::isTemplateName(Scope *S, } else { assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) || isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) || - isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD)); + isa<BuiltinTemplateDecl>(TD)); TemplateKind = - isa<VarTemplateDecl>(TD) ? TNK_Var_template : - isa<ConceptDecl>(TD) ? TNK_Concept_template : - TNK_Type_template; + isa<VarTemplateDecl>(TD) ? TNK_Var_template : TNK_Type_template; } } @@ -3036,8 +3034,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, TemplateDecl *Template = Name.getAsTemplateDecl(); if (!Template || isa<FunctionTemplateDecl>(Template) || - isa<VarTemplateDecl>(Template) || - isa<ConceptDecl>(Template)) { + isa<VarTemplateDecl>(Template)) { // We might have a substituted template template parameter pack. If so, // build a template specialization type for it. if (Name.getAsSubstTemplateTemplateParmPack()) @@ -3991,18 +3988,6 @@ Sema::CheckVarTemplateId(const CXXScopeSpec &SS, /*FoundD=*/nullptr, TemplateArgs); } -ExprResult -Sema::CheckConceptTemplateId(const CXXScopeSpec &SS, - const DeclarationNameInfo &NameInfo, - ConceptDecl *Template, - SourceLocation TemplateLoc, - const TemplateArgumentListInfo *TemplateArgs) { - // TODO: Do concept specialization here. - Diag(Template->getLocation(), diag::err_concept_feature_unimplemented) - << "can not form concept template-id"; - return ExprError(); -} - ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, @@ -7713,61 +7698,6 @@ Decl *Sema::ActOnTemplateDeclarator(Scope *S, return NewDecl; } -ConceptDecl *Sema::ActOnConceptDefinition(Scope *S, - MultiTemplateParamsArg TemplateParameterLists, IdentifierInfo *Name, - SourceLocation NameLoc, Expr *ConstraintExpr) { - // C++2a [temp.concept]p3: - // A concept-definition shall appear in the global scope or in a namespace - // scope. - assert( - CurContext->isFileContext() && - "We check during parsing that 'concept's only occur at namespace scope"); - - // Forbid any prior declaration of this name within the current namespace. - LookupResult Previous(*this, - DeclarationNameInfo(DeclarationName(Name), NameLoc), - LookupOrdinaryName); - LookupName(Previous, S); - if (!Previous.empty()) { - const NamedDecl *PrevDecl = Previous.getRepresentativeDecl(); - if (PrevDecl->getDeclContext()->Equals(CurContext)) { - if (Previous.isSingleResult() && - isa<ConceptDecl>(Previous.getFoundDecl())) { - Diag(NameLoc, diag::err_redefinition) << Name; - } else { - Diag(NameLoc, diag::err_redefinition_different_kind) << Name; - } - Diag(PrevDecl->getLocation(), diag::note_previous_decl) << PrevDecl; - return nullptr; - } - } - - ConceptDecl *NewDecl = ConceptDecl::Create(Context, CurContext, NameLoc, - Name, TemplateParameterLists[0], - ConstraintExpr); - - if (!NewDecl) - return nullptr; - - if (NewDecl->getAssociatedConstraints()) { - // C++2a [temp.concept]p4: - // A concept shall not have associated constraints. - // TODO: Make a test once we have actual associated constraints. - Diag(NameLoc, diag::err_concept_no_associated_constraints); - NewDecl->setInvalidDecl(); - } - - assert((S->isTemplateParamScope() || !TemplateParameterLists[0]->size()) && - "Not in template param scope?"); - assert(S->getParent() && !S->getParent()->isTemplateParamScope() && - "Parent scope should exist and not be template parameter."); - - ActOnDocumentableDecl(NewDecl); - PushOnScopeChains(NewDecl, S->getParent(), /*AddToContext=*/true); - - return NewDecl; -} - /// \brief Strips various properties off an implicit instantiation /// that has just been explicitly specialized. static void StripImplicitInstantiation(NamedDecl *D) { diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0ebcb03ca3..a7883c67b8 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3073,11 +3073,6 @@ Decl *TemplateDeclInstantiator::VisitFriendTemplateDecl(FriendTemplateDecl *D) { return nullptr; } -Decl *TemplateDeclInstantiator::VisitConceptDecl(ConceptDecl *D) { - llvm_unreachable("Concept definitions cannot reside inside a template"); - return nullptr; -} - Decl *TemplateDeclInstantiator::VisitDecl(Decl *D) { llvm_unreachable("Unexpected decl"); } diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp index 82809cb465..535aacb8c4 100644 --- a/lib/Serialization/ASTCommon.cpp +++ b/lib/Serialization/ASTCommon.cpp @@ -313,7 +313,6 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) { case Decl::BuiltinTemplate: case Decl::Decomposition: case Decl::Binding: - case Decl::Concept: return false; // These indirectly derive from Redeclarable<T> but are not actually diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 1b0e1bbbf7..7a5d22c00f 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -381,7 +381,6 @@ namespace clang { void VisitBindingDecl(BindingDecl *BD); void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); DeclID VisitTemplateDecl(TemplateDecl *D); - void VisitConceptDecl(ConceptDecl *D); RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); void VisitClassTemplateDecl(ClassTemplateDecl *D); void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D); @@ -2032,11 +2031,6 @@ DeclID ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { return PatternID; } -void ASTDeclReader::VisitConceptDecl(ConceptDecl *D) { - VisitTemplateDecl(D); - D->setConstraintExpr(Record.readExpr()); -} - ASTDeclReader::RedeclarableResult ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); @@ -3601,9 +3595,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { case DECL_TYPE_ALIAS_TEMPLATE: D = TypeAliasTemplateDecl::CreateDeserialized(Context, ID); break; - case DECL_CONCEPT: - D = ConceptDecl::CreateDeserialized(Context, ID); - break; case DECL_STATIC_ASSERT: D = StaticAssertDecl::CreateDeserialized(Context, ID); break; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index a055899009..7f2b1861d1 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1280,7 +1280,6 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(DECL_TEMPLATE_TYPE_PARM); RECORD(DECL_NON_TYPE_TEMPLATE_PARM); RECORD(DECL_TEMPLATE_TEMPLATE_PARM); - RECORD(DECL_CONCEPT); RECORD(DECL_TYPE_ALIAS_TEMPLATE); RECORD(DECL_STATIC_ASSERT); RECORD(DECL_CXX_BASE_SPECIFIERS); diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 432c2559e4..189de14cff 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -102,7 +102,6 @@ namespace clang { void VisitBindingDecl(BindingDecl *D); void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); void VisitTemplateDecl(TemplateDecl *D); - void VisitConceptDecl(ConceptDecl *D); void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); void VisitClassTemplateDecl(ClassTemplateDecl *D); void VisitVarTemplateDecl(VarTemplateDecl *D); @@ -1396,12 +1395,6 @@ void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) { Record.AddTemplateParameterList(D->getTemplateParameters()); } -void ASTDeclWriter::VisitConceptDecl(ConceptDecl *D) { - VisitTemplateDecl(D); - Record.AddStmt(D->getConstraintExpr()); - Code = serialization::DECL_CONCEPT; -} - void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { VisitRedeclarable(D); |