diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 184 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 37 |
4 files changed, 1 insertions, 237 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index bce493989d2..6fe2dcc9895 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -969,18 +969,6 @@ bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, return false; } -bool DeclSpec::SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID) { - if (Concept_specified) { - DiagID = diag::ext_duplicate_declspec; - PrevSpec = "concept"; - return true; - } - Concept_specified = true; - ConceptLoc = Loc; - return false; -} - void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.Sign = getTypeSpecSign(); writtenBS.Width = getTypeSpecWidth(); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 8320a7ae894..48eaceeb25a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4213,14 +4213,6 @@ Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, return TagD; } - if (DS.isConceptSpecified()) { - // C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to - // either a function concept and its definition or a variable concept and - // its initializer. - Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind); - return TagD; - } - DiagnoseFunctionSpecifiers(DS); if (DS.isFriendSpecified()) { @@ -5459,23 +5451,6 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, if (getLangOpts().CPlusPlus) CheckExtraCXXDefaultArguments(D); - if (D.getDeclSpec().isConceptSpecified()) { - // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be - // applied only to the definition of a function template or variable - // template, declared in namespace scope - if (!TemplateParamLists.size()) { - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag:: err_concept_wrong_decl_kind); - return nullptr; - } - - if (!DC->getRedeclContext()->isFileContext()) { - Diag(D.getIdentifierLoc(), - diag::err_concept_decls_may_only_appear_in_namespace_scope); - return nullptr; - } - } - NamedDecl *New; bool AddToScope = true; @@ -5694,9 +5669,6 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (D.getDeclSpec().isConstexprSpecified()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr) << 1; - if (D.getDeclSpec().isConceptSpecified()) - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_concept_wrong_decl_kind); if (D.getName().Kind != UnqualifiedId::IK_Identifier) { if (D.getName().Kind == UnqualifiedId::IK_DeductionGuideName) @@ -6553,46 +6525,6 @@ NamedDecl *Sema::ActOnVariableDeclarator( if (NewVD->isStaticDataMember() && getLangOpts().CPlusPlus17) NewVD->setImplicitlyInline(); } - - if (D.getDeclSpec().isConceptSpecified()) { - if (VarTemplateDecl *VTD = NewVD->getDescribedVarTemplate()) - VTD->setConcept(); - - // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not - // be declared with the thread_local, inline, friend, or constexpr - // specifiers, [...] - if (D.getDeclSpec().getThreadStorageClassSpec() == TSCS_thread_local) { - Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), - diag::err_concept_decl_invalid_specifiers) - << 0 << 0; - NewVD->setInvalidDecl(true); - } - - if (D.getDeclSpec().isConstexprSpecified()) { - Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_concept_decl_invalid_specifiers) - << 0 << 3; - NewVD->setInvalidDecl(true); - } - - // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be - // applied only to the definition of a function template or variable - // template, declared in namespace scope. - if (IsVariableTemplateSpecialization) { - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_concept_specified_specialization) - << (IsPartialSpecialization ? 2 : 1); - } - - // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the - // following restrictions: - // - The declared type shall have the type bool. - if (!Context.hasSameType(NewVD->getType(), Context.BoolTy) && - !NewVD->isInvalidDecl()) { - Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl); - NewVD->setInvalidDecl(true); - } - } } if (D.getDeclSpec().isInlineSpecified()) { @@ -6843,25 +6775,6 @@ NamedDecl *Sema::ActOnVariableDeclarator( if (!IsVariableTemplateSpecialization) D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous)); - // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...] - // an explicit specialization (14.8.3) or a partial specialization of a - // concept definition. - if (IsVariableTemplateSpecialization && - !D.getDeclSpec().isConceptSpecified() && !Previous.empty() && - Previous.isSingleResult()) { - NamedDecl *PreviousDecl = Previous.getFoundDecl(); - if (VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(PreviousDecl)) { - if (VarTmpl->isConcept()) { - Diag(NewVD->getLocation(), diag::err_concept_specialized) - << 1 /*variable*/ - << (IsPartialSpecialization ? 2 /*partially specialized*/ - : 1 /*explicitly specialized*/); - Diag(VarTmpl->getLocation(), diag::note_previous_declaration); - NewVD->setInvalidDecl(); - } - } - } - if (NewTemplate) { VarTemplateDecl *PrevVarTemplate = NewVD->getPreviousDecl() @@ -8315,7 +8228,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool isVirtual = D.getDeclSpec().isVirtualSpecified(); bool isExplicit = D.getDeclSpec().isExplicitSpecified(); bool isConstexpr = D.getDeclSpec().isConstexprSpecified(); - bool isConcept = D.getDeclSpec().isConceptSpecified(); isFriend = D.getDeclSpec().isFriendSpecified(); if (isFriend && !isInline && D.isFunctionDefinition()) { // C++ [class.friend]p5 @@ -8527,89 +8439,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor); } - if (isConcept) { - // This is a function concept. - if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate()) - FTD->setConcept(); - - // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be - // applied only to the definition of a function template [...] - if (!D.isFunctionDefinition()) { - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_function_concept_not_defined); - NewFD->setInvalidDecl(); - } - - // C++ Concepts TS [dcl.spec.concept]p1: [...] A function concept shall - // have no exception-specification and is treated as if it were specified - // with noexcept(true) (15.4). [...] - if (const FunctionProtoType *FPT = R->getAs<FunctionProtoType>()) { - if (FPT->hasExceptionSpec()) { - SourceRange Range; - if (D.isFunctionDeclarator()) - Range = D.getFunctionTypeInfo().getExceptionSpecRange(); - Diag(NewFD->getLocation(), diag::err_function_concept_exception_spec) - << FixItHint::CreateRemoval(Range); - NewFD->setInvalidDecl(); - } else { - Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept); - } - - // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the - // following restrictions: - // - The declared return type shall have the type bool. - if (!Context.hasSameType(FPT->getReturnType(), Context.BoolTy)) { - Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret); - NewFD->setInvalidDecl(); - } - - // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the - // following restrictions: - // - The declaration's parameter list shall be equivalent to an empty - // parameter list. - if (FPT->getNumParams() > 0 || FPT->isVariadic()) - Diag(NewFD->getLocation(), diag::err_function_concept_with_params); - } - - // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is - // implicity defined to be a constexpr declaration (implicitly inline) - NewFD->setImplicitlyInline(); - - // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not - // be declared with the thread_local, inline, friend, or constexpr - // specifiers, [...] - if (isInline) { - Diag(D.getDeclSpec().getInlineSpecLoc(), - diag::err_concept_decl_invalid_specifiers) - << 1 << 1; - NewFD->setInvalidDecl(true); - } - - if (isFriend) { - Diag(D.getDeclSpec().getFriendSpecLoc(), - diag::err_concept_decl_invalid_specifiers) - << 1 << 2; - NewFD->setInvalidDecl(true); - } - - if (isConstexpr) { - Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_concept_decl_invalid_specifiers) - << 1 << 3; - NewFD->setInvalidDecl(true); - } - - // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be - // applied only to the definition of a function template or variable - // template, declared in namespace scope. - if (isFunctionTemplateSpecialization) { - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_concept_specified_specialization) << 1; - NewFD->setInvalidDecl(true); - return NewFD; - } - } - // If __module_private__ was specified, mark the function accordingly. if (D.getDeclSpec().isModulePrivateSpecified()) { if (isFunctionTemplateSpecialization) { @@ -10825,17 +10654,6 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) { } } - // C++ Concepts TS [dcl.spec.concept]p1: [...] A variable template - // definition having the concept specifier is called a variable concept. A - // concept definition refers to [...] a variable concept and its initializer. - if (VarTemplateDecl *VTD = Var->getDescribedVarTemplate()) { - if (VTD->isConcept()) { - Diag(Var->getLocation(), diag::err_var_concept_not_initialized); - Var->setInvalidDecl(); - return; - } - } - // OpenCL v1.1 s6.5.3: variables declared in the constant address space must // be initialized. if (!Var->isInvalidDecl() && @@ -11751,8 +11569,6 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { if (DS.isConstexprSpecified()) Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr) << 0; - if (DS.isConceptSpecified()) - Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind); DiagnoseFunctionSpecifiers(DS); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 866bad137ca..00d2319e5ce 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -8342,8 +8342,7 @@ void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R, // We leave 'friend' and 'virtual' to be rejected in the normal way. if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() || DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() || - DS.isNoreturnSpecified() || DS.isConstexprSpecified() || - DS.isConceptSpecified()) { + DS.isNoreturnSpecified() || DS.isConstexprSpecified()) { BadSpecifierDiagnoser Diagnoser( *this, D.getIdentifierLoc(), diag::err_deduction_guide_invalid_specifier); @@ -8356,9 +8355,7 @@ void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R, Diagnoser.check(DS.getInlineSpecLoc(), "inline"); Diagnoser.check(DS.getNoreturnSpecLoc(), "_Noreturn"); Diagnoser.check(DS.getConstexprSpecLoc(), "constexpr"); - Diagnoser.check(DS.getConceptSpecLoc(), "concept"); DS.ClearConstexprSpec(); - DS.ClearConceptSpec(); Diagnoser.check(DS.getConstSpecLoc(), "const"); Diagnoser.check(DS.getRestrictSpecLoc(), "__restrict"); diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index d192a979959..c70a8ba8f12 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -8037,15 +8037,6 @@ bool Sema::CheckFunctionTemplateSpecialization( // Ignore access information; it doesn't figure into redeclaration checking. FunctionDecl *Specialization = cast<FunctionDecl>(*Result); - // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...] - // an explicit specialization (14.8.3) [...] of a concept definition. - if (Specialization->getPrimaryTemplate()->isConcept()) { - Diag(FD->getLocation(), diag::err_concept_specialized) - << 0 /*function*/ << 1 /*explicitly specialized*/; - Diag(Specialization->getLocation(), diag::note_previous_declaration); - return true; - } - FunctionTemplateSpecializationInfo *SpecInfo = Specialization->getTemplateSpecializationInfo(); assert(SpecInfo && "Function template specialization info missing?"); @@ -8932,15 +8923,6 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_explicit_instantiation_constexpr); - // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be - // applied only to the definition of a function template or variable template, - // declared in namespace scope. - if (D.getDeclSpec().isConceptSpecified()) { - Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_concept_specified_specialization) << 0; - return true; - } - // A deduction guide is not on the list of entities that can be explicitly // instantiated. if (Name.getNameKind() == DeclarationName::CXXDeductionGuideName) { @@ -9020,15 +9002,6 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, return true; } - // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an - // explicit instantiation (14.8.2) [...] of a concept definition. - if (PrevTemplate->isConcept()) { - Diag(D.getIdentifierLoc(), diag::err_concept_specialized) - << 1 /*variable*/ << 0 /*explicitly instantiated*/; - Diag(PrevTemplate->getLocation(), diag::note_previous_declaration); - return true; - } - // Translate the parser's template argument list into our AST format. TemplateArgumentListInfo TemplateArgs = makeTemplateArgumentListInfo(*this, *D.getName().TemplateId); @@ -9272,16 +9245,6 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, diag::ext_explicit_instantiation_without_qualified_id) << Specialization << D.getCXXScopeSpec().getRange(); - // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an - // explicit instantiation (14.8.2) [...] of a concept definition. - if (FunTmpl && FunTmpl->isConcept() && - !D.getDeclSpec().isConceptSpecified()) { - Diag(D.getIdentifierLoc(), diag::err_concept_specialized) - << 0 /*function*/ << 0 /*explicitly instantiated*/; - Diag(FunTmpl->getLocation(), diag::note_previous_declaration); - return true; - } - CheckExplicitInstantiationScope(*this, FunTmpl? (NamedDecl *)FunTmpl : Specialization->getInstantiatedFromMemberFunction(), |