Skip to content

Commit c7123aa

Browse files
committed
add default for DiagID
1 parent 7ba3d72 commit c7123aa

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3431,7 +3431,8 @@ class Sema final : public SemaBase {
34313431
bool ConstexprSupported, bool CLinkageMayDiffer);
34323432

34333433
/// type checking declaration initializers (C99 6.7.8)
3434-
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID);
3434+
bool CheckForConstantInitializer(
3435+
Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
34353436

34363437
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
34373438
QualType Type, TypeSourceInfo *TSI,

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13804,7 +13804,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1380413804
// OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
1380513805
// This is true even in C++ for OpenCL.
1380613806
} else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
13807-
CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
13807+
CheckForConstantInitializer(Init);
1380813808

1380913809
// Otherwise, C++ does not restrict the initializer.
1381013810
} else if (getLangOpts().CPlusPlus) {
@@ -13813,7 +13813,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1381313813
// C99 6.7.8p4: All the expressions in an initializer for an object that has
1381413814
// static storage duration shall be constant expressions or string literals.
1381513815
} else if (VDecl->getStorageClass() == SC_Static) {
13816-
CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
13816+
CheckForConstantInitializer(Init);
1381713817

1381813818
// C89 is stricter than C99 for aggregate initializers.
1381913819
// C89 6.5.7p3: All the expressions [...] in an initializer list
@@ -13954,7 +13954,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1395413954
// Avoid duplicate diagnostics for constexpr variables.
1395513955
if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl() &&
1395613956
!VDecl->isConstexpr())
13957-
CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
13957+
CheckForConstantInitializer(Init);
1395813958
}
1395913959

1396013960
QualType InitType = Init->getType();

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,8 +7880,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
78807880
if (!LiteralExpr->isTypeDependent() &&
78817881
!LiteralExpr->isValueDependent() &&
78827882
!literalType->isDependentType()) // C99 6.5.2.5p3
7883-
if (CheckForConstantInitializer(LiteralExpr,
7884-
diag::err_init_element_not_constant))
7883+
if (CheckForConstantInitializer(LiteralExpr))
78857884
return ExprError();
78867885
} else if (literalType.getAddressSpace() != LangAS::opencl_private &&
78877886
literalType.getAddressSpace() != LangAS::Default) {

0 commit comments

Comments
 (0)