[cfe-commits] r148209 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/CXX/expr/expr.const/p2-0x.cpp test/Misc/warning-flags.c test/Sema/PR2963-enum-constant.c test/SemaCXX/constant-expression-cxx11.cpp test/SemaCXX/constant-expression.cpp test/SemaCXX/enum-bitfield.cpp test/SemaCXX/enum.cpp test/SemaCXX/i-c-e-cxx.cpp test/SemaTemplate/instantiate-expr-1.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sat Jan 14 19:51:30 PST 2012
Author: rsmith
Date: Sat Jan 14 21:51:30 2012
New Revision: 148209
URL: http://llvm.org/viewvc/llvm-project?rev=148209&view=rev
Log:
Pedantic diagnostic correction: in C++, we have integral constant expressions,
not integer constant expressions. In passing, fix the 'folding is an extension'
diagnostic to not claim we're accepting the code, since that's not true in
-pedantic-errors mode, and add this diagnostic to -Wgnu.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
cfe/trunk/test/Misc/warning-flags.c
cfe/trunk/test/Sema/PR2963-enum-constant.c
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/test/SemaCXX/constant-expression.cpp
cfe/trunk/test/SemaCXX/enum-bitfield.cpp
cfe/trunk/test/SemaCXX/enum.cpp
cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 14 21:51:30 2012
@@ -16,10 +16,10 @@
// 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<
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Jan 14 21:51:30 2012
@@ -9268,9 +9268,11 @@
}
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 @@
}
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();
Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp Sat Jan 14 21:51:30 2012
@@ -136,7 +136,7 @@
}
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 {
Modified: cfe/trunk/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Sat Jan 14 21:51:30 2012
@@ -17,7 +17,7 @@
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_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
Modified: cfe/trunk/test/Sema/PR2963-enum-constant.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2963-enum-constant.c?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/Sema/PR2963-enum-constant.c (original)
+++ cfe/trunk/test/Sema/PR2963-enum-constant.c Sat Jan 14 21:51:30 2012
@@ -13,5 +13,5 @@
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}}
};
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Sat Jan 14 21:51:30 2012
@@ -93,7 +93,7 @@
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 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}}
};
Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression.cpp Sat Jan 14 21:51:30 2012
@@ -88,10 +88,10 @@
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}}
;
}
}
Modified: cfe/trunk/test/SemaCXX/enum-bitfield.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-bitfield.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-bitfield.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-bitfield.cpp Sat Jan 14 21:51:30 2012
@@ -14,5 +14,5 @@
struct Y {
enum E : int(2);
- enum E : Z(); // expected-error{{not an integer constant}}
+ enum E : Z(); // expected-error{{not an integral constant}}
};
Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Sat Jan 14 21:51:30 2012
@@ -88,7 +88,7 @@
// 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() {
Modified: cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp (original)
+++ cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp Sat Jan 14 21:51:30 2012
@@ -18,7 +18,7 @@
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}}
}
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp?rev=148209&r1=148208&r2=148209&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp Sat Jan 14 21:51:30 2012
@@ -34,7 +34,7 @@
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}}
};
More information about the cfe-commits
mailing list