aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Sema/DeclSpec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/DeclSpec.cpp')
-rw-r--r--lib/Sema/DeclSpec.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp
index 77e5eb095693..639231c87232 100644
--- a/lib/Sema/DeclSpec.cpp
+++ b/lib/Sema/DeclSpec.cpp
@@ -569,6 +569,7 @@ const char *DeclSpec::getSpecifierName(ConstexprSpecKind C) {
case CSK_unspecified: return "unspecified";
case CSK_constexpr: return "constexpr";
case CSK_consteval: return "consteval";
+ case CSK_constinit: return "constinit";
}
llvm_unreachable("Unknown ConstexprSpecKind");
}
@@ -1036,13 +1037,9 @@ bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
bool DeclSpec::SetConstexprSpec(ConstexprSpecKind ConstexprKind,
SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID) {
- if (getConstexprSpecifier() != CSK_unspecified) {
- if (getConstexprSpecifier() == CSK_consteval || ConstexprKind == CSK_consteval)
- return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec, DiagID);
- DiagID = diag::warn_duplicate_declspec;
- PrevSpec = "constexpr";
- return true;
- }
+ if (getConstexprSpecifier() != CSK_unspecified)
+ return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec,
+ DiagID);
ConstexprSpecifier = ConstexprKind;
ConstexprLoc = Loc;
return false;
@@ -1291,8 +1288,10 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
<< (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
if (getConstexprSpecifier() == CSK_constexpr)
S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
- if (getConstexprSpecifier() == CSK_consteval)
+ else if (getConstexprSpecifier() == CSK_consteval)
S.Diag(ConstexprLoc, diag::warn_cxx20_compat_consteval);
+ else if (getConstexprSpecifier() == CSK_constinit)
+ S.Diag(ConstexprLoc, diag::warn_cxx20_compat_constinit);
// C++ [class.friend]p6:
// No storage-class-specifier shall appear in the decl-specifier-seq
// of a friend declaration.