aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td6
-rw-r--r--lib/Sema/SemaExpr.cpp17
-rw-r--r--test/CXX/expr/expr.const/p2-0x.cpp2
-rw-r--r--test/Misc/warning-flags.c3
-rw-r--r--test/Sema/PR2963-enum-constant.c2
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp17
-rw-r--r--test/SemaCXX/constant-expression.cpp8
-rw-r--r--test/SemaCXX/enum-bitfield.cpp2
-rw-r--r--test/SemaCXX/enum.cpp2
-rw-r--r--test/SemaCXX/i-c-e-cxx.cpp2
-rw-r--r--test/SemaTemplate/instantiate-expr-1.cpp2
11 files changed, 30 insertions, 33 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index a114dd35bc..049074d6e5 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -16,10 +16,10 @@ let CategoryName = "Semantic Issue" in {
// Constant expressions
def err_expr_not_ice : Error<
- "expression is not an integer constant expression">;
+ "expression is not an %select{integer|integral}0 constant expression">;
def ext_expr_not_ice : Extension<
- "expression is not integer constant expression "
- "(but is allowed as an extension)">;
+ "expression is not an %select{integer|integral}0 constant expression; "
+ "folding it to a constant is a GNU extension">, InGroup<GNU>;
// Semantic analysis of constant literals.
def ext_predef_outside_function : Warning<
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 75caa6f585..e2a9404d21 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -9268,9 +9268,11 @@ bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result,
}
if (!Folded || !AllowFold) {
- Diag(E->getSourceRange().getBegin(),
- DiagID ? DiagID : unsigned(diag::err_expr_not_ice))
- << E->getSourceRange();
+ if (DiagID)
+ Diag(E->getSourceRange().getBegin(), DiagID) << E->getSourceRange();
+ else
+ Diag(E->getSourceRange().getBegin(), diag::err_expr_not_ice)
+ << E->getSourceRange() << LangOpts.CPlusPlus;
// We only show the notes if they're not the usual "invalid subexpression"
// or if they are actually in a subexpression.
@@ -9285,12 +9287,9 @@ bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result,
}
Diag(E->getSourceRange().getBegin(), diag::ext_expr_not_ice)
- << E->getSourceRange();
-
- if (Diags.getDiagnosticLevel(diag::ext_expr_not_ice, E->getExprLoc())
- != DiagnosticsEngine::Ignored)
- for (unsigned I = 0, N = Notes.size(); I != N; ++I)
- Diag(Notes[I].first, Notes[I].second);
+ << E->getSourceRange() << LangOpts.CPlusPlus;
+ for (unsigned I = 0, N = Notes.size(); I != N; ++I)
+ Diag(Notes[I].first, Notes[I].second);
if (Result)
*Result = EvalResult.Val.getInt();
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index cece22d9b2..05ebb31eff 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -136,7 +136,7 @@ namespace UndefinedBehavior {
}
constexpr int n = (f(p), 0); // expected-error {{constant expression}} expected-note {{in call to 'f(&s.m + 1)'}}
struct T {
- int n : f(p); // expected-error {{not an integer constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+ int n : f(p); // expected-error {{not an integral constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
};
namespace Ptr {
diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c
index 42c09cbe7d..29225f249a 100644
--- a/test/Misc/warning-flags.c
+++ b/test/Misc/warning-flags.c
@@ -17,7 +17,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (267):
+CHECK: Warnings without flags (266):
CHECK-NEXT: ext_anon_param_requires_type_specifier
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_array_init_copy
@@ -35,7 +35,6 @@ CHECK-NEXT: ext_enumerator_list_comma
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_instantiation_without_qualified_id
CHECK-NEXT: ext_explicit_specialization_storage_class
-CHECK-NEXT: ext_expr_not_ice
CHECK-NEXT: ext_extra_ivar_semi
CHECK-NEXT: ext_extra_struct_semi
CHECK-NEXT: ext_forward_ref_enum
diff --git a/test/Sema/PR2963-enum-constant.c b/test/Sema/PR2963-enum-constant.c
index 1900eefc7c..43daabf58e 100644
--- a/test/Sema/PR2963-enum-constant.c
+++ b/test/Sema/PR2963-enum-constant.c
@@ -13,5 +13,5 @@ enum
enum
{
- SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not integer constant expression}}
+ SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not an integer constant expression}}
};
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index e20f8f32b5..b1b4f38a4b 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -93,7 +93,7 @@ namespace CaseStatements {
void f(int n) {
switch (n) {
// FIXME: Produce the 'add ()' fixit for this.
- case MemberZero().zero: // desired-error {{did you mean to call it with no arguments?}} expected-error {{not an integer constant expression}} expected-note {{non-literal type '<bound member function type>'}}
+ case MemberZero().zero: // desired-error {{did you mean to call it with no arguments?}} expected-error {{not an integral constant expression}} expected-note {{non-literal type '<bound member function type>'}}
case id(1):
return;
}
@@ -299,27 +299,26 @@ constexpr S* sptr = &s;
constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // expected-error {{constant expression}} expected-note {{dynamic_cast}}
struct Str {
- // FIXME: In C++ mode, we should say 'integral' not 'integer'
int a : dynamic_cast<S*>(sptr) == dynamic_cast<S*>(sptr); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{dynamic_cast is not allowed in a constant expression}}
int b : reinterpret_cast<S*>(sptr) == reinterpret_cast<S*>(sptr); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{reinterpret_cast is not allowed in a constant expression}}
int c : (S*)(long)(sptr) == (S*)(long)(sptr); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
int d : (S*)(42) == (S*)(42); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
int e : (Str*)(sptr) == (Str*)(sptr); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
int f : &(Str&)(*sptr) == &(Str&)(*sptr); // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
int g : (S*)(void*)(sptr) == sptr; // \
- expected-warning {{not integer constant expression}} \
+ expected-warning {{not an integral constant expression}} \
expected-note {{cast from 'void *' is not allowed in a constant expression}}
};
diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp
index 061e77591b..23a4dda708 100644
--- a/test/SemaCXX/constant-expression.cpp
+++ b/test/SemaCXX/constant-expression.cpp
@@ -88,10 +88,10 @@ enum {
void diags(int n) {
switch (n) {
- case (1/0, 1): // expected-error {{not an integer constant expression}} expected-note {{division by zero}}
- case (int)(1/0, 2.0): // expected-error {{not an integer constant expression}} expected-note {{division by zero}}
- case __imag(1/0): // expected-error {{not an integer constant expression}} expected-note {{division by zero}}
- case (int)__imag((double)(1/0)): // expected-error {{not an integer constant expression}} expected-note {{division by zero}}
+ case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
;
}
}
diff --git a/test/SemaCXX/enum-bitfield.cpp b/test/SemaCXX/enum-bitfield.cpp
index 1a657408f8..831b982511 100644
--- a/test/SemaCXX/enum-bitfield.cpp
+++ b/test/SemaCXX/enum-bitfield.cpp
@@ -14,5 +14,5 @@ struct X {
struct Y {
enum E : int(2);
- enum E : Z(); // expected-error{{not an integer constant}}
+ enum E : Z(); // expected-error{{not an integral constant}}
};
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index b4a050cb09..370e1c34d2 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -88,7 +88,7 @@ typedef enum { }; // expected-warning{{typedef requires a name}}
// PR7921
enum PR7921E {
- PR7921V = (PR7921E)(123) // expected-error {{expression is not an integer constant expression}}
+ PR7921V = (PR7921E)(123) // expected-error {{expression is not an integral constant expression}}
};
void PR8089() {
diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp
index 47a47b5e2f..0bfd221a4c 100644
--- a/test/SemaCXX/i-c-e-cxx.cpp
+++ b/test/SemaCXX/i-c-e-cxx.cpp
@@ -18,7 +18,7 @@ void f() {
int a() {
const int t=t; // expected-note {{declared here}}
switch(1) { // expected-warning {{no case matching constant switch condition '1'}}
- case t:; // expected-error {{not an integer constant expression}} expected-note {{initializer of 't' is not a constant expression}}
+ case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}}
}
}
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 08f5e9d9a7..9395117e9c 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -34,7 +34,7 @@ void test_BitfieldMinus() {
template<int I, int J>
struct BitfieldDivide {
- int bitfield : I / J; // expected-error{{expression is not an integer constant expression}} \
+ int bitfield : I / J; // expected-error{{expression is not an integral constant expression}} \
// expected-note{{division by zero}}
};