Index: clang/include/clang/AST/Decl.h =================================================================== --- clang/include/clang/AST/Decl.h +++ clang/include/clang/AST/Decl.h @@ -1978,7 +1978,7 @@ SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false, bool hasWrittenPrototype = true, - ConstexprSpecKind ConstexprKind = CSK_unspecified, + ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause = nullptr) { DeclarationNameInfo NameInfo(N, NLoc); return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC, @@ -2230,19 +2230,19 @@ /// Whether this is a (C++11) constexpr function or constexpr constructor. bool isConstexpr() const { - return FunctionDeclBits.ConstexprKind != CSK_unspecified; + return getConstexprKind() != ConstexprSpecKind::Unspecified; } void setConstexprKind(ConstexprSpecKind CSK) { - FunctionDeclBits.ConstexprKind = CSK; + FunctionDeclBits.ConstexprKind = static_cast(CSK); } ConstexprSpecKind getConstexprKind() const { return static_cast(FunctionDeclBits.ConstexprKind); } bool isConstexprSpecified() const { - return FunctionDeclBits.ConstexprKind == CSK_constexpr; + return getConstexprKind() == ConstexprSpecKind::Constexpr; } bool isConsteval() const { - return FunctionDeclBits.ConstexprKind == CSK_consteval; + return getConstexprKind() == ConstexprSpecKind::Consteval; } /// Whether the instantiation of this function is pending. Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1887,7 +1887,7 @@ const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, - SC_None, false, CSK_unspecified), + SC_None, false, ConstexprSpecKind::Unspecified), ExplicitSpec(ES) { if (EndLocation.isValid()) setRangeEnd(EndLocation); Index: clang/include/clang/Basic/Specifiers.h =================================================================== --- clang/include/clang/Basic/Specifiers.h +++ clang/include/clang/Basic/Specifiers.h @@ -29,12 +29,7 @@ }; /// Define the kind of constexpr specifier. - enum ConstexprSpecKind { - CSK_unspecified, - CSK_constexpr, - CSK_consteval, - CSK_constinit - }; + enum class ConstexprSpecKind { Unspecified, Constexpr, Consteval, Constinit }; /// Specifies the width of a type, e.g., short, long, or long long. enum class TypeSpecifierWidth { Unspecified, Short, Long, LongLong }; Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -431,8 +431,10 @@ TypeQualifiers(TQ_unspecified), FS_inline_specified(false), FS_forceinline_specified(false), FS_virtual_specified(false), FS_noreturn_specified(false), Friend_specified(false), - ConstexprSpecifier(CSK_unspecified), FS_explicit_specifier(), - Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {} + ConstexprSpecifier( + static_cast(ConstexprSpecKind::Unspecified)), + FS_explicit_specifier(), Attrs(attrFactory), writtenBS(), + ObjCQualifiers(nullptr) {} // storage-class-specifier SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; } @@ -755,11 +757,11 @@ SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } bool hasConstexprSpecifier() const { - return ConstexprSpecifier != CSK_unspecified; + return getConstexprSpecifier() != ConstexprSpecKind::Unspecified; } void ClearConstexprSpec() { - ConstexprSpecifier = CSK_unspecified; + ConstexprSpecifier = static_cast(ConstexprSpecKind::Unspecified); ConstexprLoc = SourceLocation(); } Index: clang/lib/AST/Decl.cpp =================================================================== --- clang/lib/AST/Decl.cpp +++ clang/lib/AST/Decl.cpp @@ -2834,7 +2834,7 @@ FunctionDeclBits.HasDefaultedFunctionInfo = false; FunctionDeclBits.HasImplicitReturnZero = false; FunctionDeclBits.IsLateTemplateParsed = false; - FunctionDeclBits.ConstexprKind = ConstexprKind; + FunctionDeclBits.ConstexprKind = static_cast(ConstexprKind); FunctionDeclBits.InstantiationIsPending = false; FunctionDeclBits.UsesSEHTry = false; FunctionDeclBits.UsesFPIntrin = false; @@ -4827,9 +4827,9 @@ } FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FunctionDecl(Function, C, nullptr, SourceLocation(), - DeclarationNameInfo(), QualType(), nullptr, - SC_None, false, CSK_unspecified, nullptr); + return new (C, ID) FunctionDecl( + Function, C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), + nullptr, SC_None, false, ConstexprSpecKind::Unspecified, nullptr); } BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { Index: clang/lib/AST/DeclCXX.cpp =================================================================== --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -2187,10 +2187,10 @@ } CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) CXXMethodDecl( - CXXMethod, C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, SC_None, false, CSK_unspecified, SourceLocation(), - nullptr); + return new (C, ID) + CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(), + DeclarationNameInfo(), QualType(), nullptr, SC_None, false, + ConstexprSpecKind::Unspecified, SourceLocation(), nullptr); } CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base, @@ -2589,10 +2589,10 @@ unsigned Extra = additionalSizeToAlloc( isInheritingConstructor, hasTraillingExplicit); - auto *Result = new (C, ID, Extra) - CXXConstructorDecl(C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, ExplicitSpecifier(), false, false, - CSK_unspecified, InheritedConstructor(), nullptr); + auto *Result = new (C, ID, Extra) CXXConstructorDecl( + C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, + ExplicitSpecifier(), false, false, ConstexprSpecKind::Unspecified, + InheritedConstructor(), nullptr); Result->setInheritingConstructor(isInheritingConstructor); Result->CXXConstructorDeclBits.HasTrailingExplicitSpecifier = hasTraillingExplicit; @@ -2730,10 +2730,9 @@ CXXDestructorDecl * CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) - CXXDestructorDecl(C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, false, false, CSK_unspecified, - nullptr); + return new (C, ID) CXXDestructorDecl( + C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, + false, false, ConstexprSpecKind::Unspecified, nullptr); } CXXDestructorDecl *CXXDestructorDecl::Create( @@ -2766,7 +2765,8 @@ CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) CXXConversionDecl( C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, - false, ExplicitSpecifier(), CSK_unspecified, SourceLocation(), nullptr); + false, ExplicitSpecifier(), ConstexprSpecKind::Unspecified, + SourceLocation(), nullptr); } CXXConversionDecl *CXXConversionDecl::Create( Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -2438,7 +2438,7 @@ // Issue diagnostic and remove constexpr specifier if present. if (DS.hasConstexprSpecifier() && DSC != DeclSpecContext::DSC_condition) { Diag(DS.getConstexprSpecLoc(), diag::err_typename_invalid_constexpr) - << DS.getConstexprSpecifier(); + << static_cast(DS.getConstexprSpecifier()); DS.ClearConstexprSpec(); } } @@ -3679,13 +3679,16 @@ // constexpr, consteval, constinit specifiers case tok::kw_constexpr: - isInvalid = DS.SetConstexprSpec(CSK_constexpr, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Constexpr, Loc, + PrevSpec, DiagID); break; case tok::kw_consteval: - isInvalid = DS.SetConstexprSpec(CSK_consteval, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Consteval, Loc, + PrevSpec, DiagID); break; case tok::kw_constinit: - isInvalid = DS.SetConstexprSpec(CSK_constinit, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Constinit, Loc, + PrevSpec, DiagID); break; // type-specifier Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -1206,7 +1206,8 @@ : diag::warn_cxx14_compat_constexpr_on_lambda); const char *PrevSpec = nullptr; unsigned DiagID = 0; - DS.SetConstexprSpec(CSK_constexpr, ConstexprLoc, PrevSpec, DiagID); + DS.SetConstexprSpec(ConstexprSpecKind::Constexpr, ConstexprLoc, PrevSpec, + DiagID); assert(PrevSpec == nullptr && DiagID == 0 && "Constexpr cannot have been set previously!"); } @@ -1219,7 +1220,8 @@ P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval); const char *PrevSpec = nullptr; unsigned DiagID = 0; - DS.SetConstexprSpec(CSK_consteval, ConstevalLoc, PrevSpec, DiagID); + DS.SetConstexprSpec(ConstexprSpecKind::Consteval, ConstevalLoc, PrevSpec, + DiagID); if (DiagID != 0) P.Diag(ConstevalLoc, DiagID) << PrevSpec; } Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -588,10 +588,14 @@ const char *DeclSpec::getSpecifierName(ConstexprSpecKind C) { switch (C) { - case CSK_unspecified: return "unspecified"; - case CSK_constexpr: return "constexpr"; - case CSK_consteval: return "consteval"; - case CSK_constinit: return "constinit"; + case ConstexprSpecKind::Unspecified: + return "unspecified"; + case ConstexprSpecKind::Constexpr: + return "constexpr"; + case ConstexprSpecKind::Consteval: + return "consteval"; + case ConstexprSpecKind::Constinit: + return "constinit"; } llvm_unreachable("Unknown ConstexprSpecKind"); } @@ -1085,10 +1089,10 @@ bool DeclSpec::SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { - if (getConstexprSpecifier() != CSK_unspecified) + if (getConstexprSpecifier() != ConstexprSpecKind::Unspecified) return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec, DiagID); - ConstexprSpecifier = ConstexprKind; + ConstexprSpecifier = static_cast(ConstexprKind); ConstexprLoc = Loc; return false; } @@ -1354,11 +1358,11 @@ else if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32) S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type) << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t"); - if (getConstexprSpecifier() == CSK_constexpr) + if (getConstexprSpecifier() == ConstexprSpecKind::Constexpr) S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr); - else if (getConstexprSpecifier() == CSK_consteval) + else if (getConstexprSpecifier() == ConstexprSpecKind::Consteval) S.Diag(ConstexprLoc, diag::warn_cxx20_compat_consteval); - else if (getConstexprSpecifier() == CSK_constinit) + else if (getConstexprSpecifier() == ConstexprSpecKind::Constinit) S.Diag(ConstexprLoc, diag::warn_cxx20_compat_constinit); // C++ [class.friend]p6: // No storage-class-specifier shall appear in the decl-specifier-seq Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -4599,10 +4599,10 @@ if (Tag) Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_tag) << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType()) - << DS.getConstexprSpecifier(); + << static_cast(DS.getConstexprSpecifier()); else Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_wrong_decl_kind) - << DS.getConstexprSpecifier(); + << static_cast(DS.getConstexprSpecifier()); // Don't emit warnings after this error. return TagD; } @@ -6082,7 +6082,7 @@ << getLangOpts().CPlusPlus17; if (D.getDeclSpec().hasConstexprSpecifier()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr) - << 1 << D.getDeclSpec().getConstexprSpecifier(); + << 1 << static_cast(D.getDeclSpec().getConstexprSpecifier()); if (D.getName().Kind != UnqualifiedIdKind::IK_Identifier) { if (D.getName().Kind == UnqualifiedIdKind::IK_DeductionGuideName) @@ -7124,16 +7124,16 @@ } switch (D.getDeclSpec().getConstexprSpecifier()) { - case CSK_unspecified: + case ConstexprSpecKind::Unspecified: break; - case CSK_consteval: + case ConstexprSpecKind::Consteval: Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_constexpr_wrong_decl_kind) - << D.getDeclSpec().getConstexprSpecifier(); + diag::err_constexpr_wrong_decl_kind) + << static_cast(D.getDeclSpec().getConstexprSpecifier()); LLVM_FALLTHROUGH; - case CSK_constexpr: + case ConstexprSpecKind::Constexpr: NewVD->setConstexpr(true); MaybeAddCUDAConstantAttr(NewVD); // C++1z [dcl.spec.constexpr]p1: @@ -7145,7 +7145,7 @@ NewVD->setImplicitlyInline(); break; - case CSK_constinit: + case ConstexprSpecKind::Constinit: if (!NewVD->hasGlobalStorage()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constinit_local_variable); @@ -8424,7 +8424,7 @@ NewFD = FunctionDecl::Create(SemaRef.Context, DC, D.getBeginLoc(), NameInfo, R, TInfo, SC, isInline, HasPrototype, - CSK_unspecified, + ConstexprSpecKind::Unspecified, /*TrailingRequiresClause=*/nullptr); if (D.isInvalidType()) NewFD->setInvalidDecl(); @@ -8435,11 +8435,11 @@ ExplicitSpecifier ExplicitSpecifier = D.getDeclSpec().getExplicitSpecifier(); ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier(); - if (ConstexprKind == CSK_constinit) { + if (ConstexprKind == ConstexprSpecKind::Constinit) { SemaRef.Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_wrong_decl_kind) - << ConstexprKind; - ConstexprKind = CSK_unspecified; + << static_cast(ConstexprKind); + ConstexprKind = ConstexprSpecKind::Unspecified; D.getMutableDeclSpec().ClearConstexprSpec(); } Expr *TrailingRequiresClause = D.getTrailingRequiresClause(); @@ -9103,8 +9103,8 @@ } } - if (ConstexprSpecKind ConstexprKind = - D.getDeclSpec().getConstexprSpecifier()) { + ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier(); + if (ConstexprKind != ConstexprSpecKind::Unspecified) { // C++11 [dcl.constexpr]p2: constexpr functions and constexpr constructors // are implicitly inline. NewFD->setImplicitlyInline(); @@ -9113,15 +9113,18 @@ // be either constructors or to return a literal type. Therefore, // destructors cannot be declared constexpr. if (isa(NewFD) && - (!getLangOpts().CPlusPlus20 || ConstexprKind == CSK_consteval)) { + (!getLangOpts().CPlusPlus20 || + ConstexprKind == ConstexprSpecKind::Consteval)) { Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor) - << ConstexprKind; - NewFD->setConstexprKind(getLangOpts().CPlusPlus20 ? CSK_unspecified : CSK_constexpr); + << static_cast(ConstexprKind); + NewFD->setConstexprKind(getLangOpts().CPlusPlus20 + ? ConstexprSpecKind::Unspecified + : ConstexprSpecKind::Constexpr); } // C++20 [dcl.constexpr]p2: An allocation function, or a // deallocation function shall not be declared with the consteval // specifier. - if (ConstexprKind == CSK_consteval && + if (ConstexprKind == ConstexprSpecKind::Consteval && (NewFD->getOverloadedOperator() == OO_New || NewFD->getOverloadedOperator() == OO_Array_New || NewFD->getOverloadedOperator() == OO_Delete || @@ -9129,7 +9132,7 @@ Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_consteval_decl_kind) << NewFD; - NewFD->setConstexprKind(CSK_constexpr); + NewFD->setConstexprKind(ConstexprSpecKind::Constexpr); } } @@ -10988,7 +10991,7 @@ Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main) << FD->isConsteval() << FixItHint::CreateRemoval(DS.getConstexprSpecLoc()); - FD->setConstexprKind(CSK_unspecified); + FD->setConstexprKind(ConstexprSpecKind::Unspecified); } if (getLangOpts().OpenCL) { @@ -13514,7 +13517,7 @@ << getLangOpts().CPlusPlus17; if (DS.hasConstexprSpecifier()) Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr) - << 0 << D.getDeclSpec().getConstexprSpecifier(); + << 0 << static_cast(D.getDeclSpec().getConstexprSpecifier()); DiagnoseFunctionSpecifiers(DS); Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -8176,8 +8176,8 @@ NewFD = FunctionDecl::Create( FD->getASTContext(), FD->getDeclContext(), Loc, Loc, DeclarationName(II), FD->getType(), FD->getTypeSourceInfo(), SC_None, - false /*isInlineSpecified*/, FD->hasPrototype(), CSK_unspecified, - FD->getTrailingRequiresClause()); + false /*isInlineSpecified*/, FD->hasPrototype(), + ConstexprSpecKind::Unspecified, FD->getTrailingRequiresClause()); NewD = NewFD; if (FD->getQualifier()) Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -655,7 +655,8 @@ // contain the constexpr specifier. if (New->getConstexprKind() != Old->getConstexprKind()) { Diag(New->getLocation(), diag::err_constexpr_redecl_mismatch) - << New << New->getConstexprKind() << Old->getConstexprKind(); + << New << static_cast(New->getConstexprKind()) + << static_cast(Old->getConstexprKind()); Diag(Old->getLocation(), diag::note_previous_declaration); Invalid = true; } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() && @@ -1642,7 +1643,7 @@ if (Kind == Sema::CheckConstexprKind::Diagnose) { SemaRef.Diag(DD->getLocation(), diag::err_constexpr_dtor_subobject) - << DD->getConstexprKind() << !FD + << static_cast(DD->getConstexprKind()) << !FD << (FD ? FD->getDeclName() : DeclarationName()) << T; SemaRef.Diag(Loc, diag::note_constexpr_dtor_subobject) << !FD << (FD ? FD->getDeclName() : DeclarationName()) << T; @@ -7368,9 +7369,10 @@ // If a function is explicitly defaulted on its first declaration, it is // implicitly considered to be constexpr if the implicit declaration // would be. - MD->setConstexprKind( - Constexpr ? (MD->isConsteval() ? CSK_consteval : CSK_constexpr) - : CSK_unspecified); + MD->setConstexprKind(Constexpr ? (MD->isConsteval() + ? ConstexprSpecKind::Consteval + : ConstexprSpecKind::Constexpr) + : ConstexprSpecKind::Unspecified); if (!Type->hasExceptionSpec()) { // C++2a [except.spec]p3: @@ -8462,7 +8464,7 @@ // FIXME: Only applying this to the first declaration seems problematic, as // simple reorderings can affect the meaning of the program. if (First && !FD->isConstexpr() && Info.Constexpr) - FD->setConstexprKind(CSK_constexpr); + FD->setConstexprKind(ConstexprSpecKind::Constexpr); // C++2a [except.spec]p3: // If a declaration of a function does not have a noexcept-specifier @@ -12974,7 +12976,8 @@ Context, ClassDecl, ClassLoc, NameInfo, /*Type*/ QualType(), /*TInfo=*/nullptr, ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); DefaultCon->setAccess(AS_public); DefaultCon->setDefaulted(); @@ -13095,7 +13098,7 @@ Context, Derived, UsingLoc, NameInfo, TInfo->getType(), TInfo, BaseCtor->getExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? BaseCtor->getConstexprKind() : CSK_unspecified, + Constexpr ? BaseCtor->getConstexprKind() : ConstexprSpecKind::Unspecified, InheritedConstructor(Shadow, BaseCtor), BaseCtor->getTrailingRequiresClause()); if (Shadow->isInvalidDecl()) @@ -13252,7 +13255,8 @@ CXXDestructorDecl::Create(Context, ClassDecl, ClassLoc, NameInfo, QualType(), nullptr, /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); Destructor->setAccess(AS_public); Destructor->setDefaulted(); @@ -13887,7 +13891,8 @@ CXXMethodDecl *CopyAssignment = CXXMethodDecl::Create( Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*StorageClass=*/SC_None, - /*isInline=*/true, Constexpr ? CSK_constexpr : CSK_unspecified, + /*isInline=*/true, + Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, SourceLocation()); CopyAssignment->setAccess(AS_public); CopyAssignment->setDefaulted(); @@ -14212,7 +14217,8 @@ CXXMethodDecl *MoveAssignment = CXXMethodDecl::Create( Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*StorageClass=*/SC_None, - /*isInline=*/true, Constexpr ? CSK_constexpr : CSK_unspecified, + /*isInline=*/true, + Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, SourceLocation()); MoveAssignment->setAccess(AS_public); MoveAssignment->setDefaulted(); @@ -14596,7 +14602,8 @@ ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); CopyConstructor->setAccess(AS_public); CopyConstructor->setDefaulted(); @@ -14729,7 +14736,8 @@ ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); MoveConstructor->setAccess(AS_public); MoveConstructor->setDefaulted(); Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -18973,7 +18973,7 @@ S.Context, FD->getDeclContext(), Loc, Loc, FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(), SC_None, false /*isInlineSpecified*/, FD->hasPrototype(), - /*ConstexprKind*/ CSK_unspecified); + /*ConstexprKind*/ ConstexprSpecKind::Unspecified); if (FD->getQualifier()) NewFD->setQualifierInfo(FD->getQualifierLoc()); Index: clang/lib/Sema/SemaLambda.cpp =================================================================== --- clang/lib/Sema/SemaLambda.cpp +++ clang/lib/Sema/SemaLambda.cpp @@ -1439,7 +1439,8 @@ S.Context, Class, Loc, DeclarationNameInfo(ConversionName, Loc, ConvNameLoc), ConvTy, ConvTSI, /*isInline=*/true, ExplicitSpecifier(), - S.getLangOpts().CPlusPlus17 ? CSK_constexpr : CSK_unspecified, + S.getLangOpts().CPlusPlus17 ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified, CallOperator->getBody()->getEndLoc()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1478,7 +1479,8 @@ CXXMethodDecl *Invoke = CXXMethodDecl::Create( S.Context, Class, Loc, DeclarationNameInfo(InvokerName, Loc), InvokerFunctionTy, CallOperator->getTypeSourceInfo(), SC_Static, - /*isInline=*/true, CSK_unspecified, CallOperator->getBody()->getEndLoc()); + /*isInline=*/true, ConstexprSpecKind::Unspecified, + CallOperator->getBody()->getEndLoc()); for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) InvokerParams[I]->setOwningFunction(Invoke); Invoke->setParams(InvokerParams); @@ -1545,7 +1547,7 @@ CXXConversionDecl *Conversion = CXXConversionDecl::Create( S.Context, Class, Loc, DeclarationNameInfo(Name, Loc, NameLoc), ConvTy, S.Context.getTrivialTypeSourceInfo(ConvTy, Loc), - /*isInline=*/true, ExplicitSpecifier(), CSK_unspecified, + /*isInline=*/true, ExplicitSpecifier(), ConstexprSpecKind::Unspecified, CallOperator->getBody()->getEndLoc()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1909,8 +1911,8 @@ CallOperator->setConstexprKind( CheckConstexprFunctionDefinition(CallOperator, CheckConstexprKind::CheckValid) - ? CSK_constexpr - : CSK_unspecified); + ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); } // Emit delayed shadowing warnings now that the full capture list is known. Index: clang/lib/Sema/SemaOpenMP.cpp =================================================================== --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -5902,8 +5902,10 @@ TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType FType = TInfo->getType(); - bool IsConstexpr = D.getDeclSpec().getConstexprSpecifier() == CSK_constexpr; - bool IsConsteval = D.getDeclSpec().getConstexprSpecifier() == CSK_consteval; + bool IsConstexpr = + D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Constexpr; + bool IsConsteval = + D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Consteval; for (auto *Candidate : Lookup) { auto *CandidateDecl = Candidate->getUnderlyingDecl(); Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -5549,7 +5549,7 @@ // C++0x [dcl.constexpr]p9: // A constexpr specifier used in an object declaration declares the object // as const. - if (D.getDeclSpec().getConstexprSpecifier() == CSK_constexpr && + if (D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Constexpr && T->isObjectType()) T.addConst(); Index: clang/lib/Serialization/ASTWriterDecl.cpp =================================================================== --- clang/lib/Serialization/ASTWriterDecl.cpp +++ clang/lib/Serialization/ASTWriterDecl.cpp @@ -557,7 +557,7 @@ Record.push_back(D->isDefaulted()); Record.push_back(D->isExplicitlyDefaulted()); Record.push_back(D->hasImplicitReturnZero()); - Record.push_back(D->getConstexprKind()); + Record.push_back(static_cast(D->getConstexprKind())); Record.push_back(D->usesSEHTry()); Record.push_back(D->hasSkippedBody()); Record.push_back(D->isMultiVersion());