r173841 - Move -Wstatic-float-init fixit into a note & don't recover as if constexpr
David Blaikie
dblaikie at gmail.com
Tue Jan 29 14:26:09 PST 2013
Author: dblaikie
Date: Tue Jan 29 16:26:08 2013
New Revision: 173841
URL: http://llvm.org/viewvc/llvm-project?rev=173841&view=rev
Log:
Move -Wstatic-float-init fixit into a note & don't recover as if constexpr
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/class/class.static/class.static.data/p3.cpp
cfe/trunk/test/CXX/class/class.union/p2-0x.cpp
cfe/trunk/test/SemaCXX/cxx0x-class.cpp
cfe/trunk/test/SemaCXX/warn-static-const-float.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 29 16:26:08 2013
@@ -5311,6 +5311,7 @@ def ext_in_class_initializer_float_type
def ext_in_class_initializer_float_type_cxx11 : ExtWarn<
"in-class initializer for static data member of type %0 requires "
"'constexpr' specifier">, InGroup<StaticFloatInit>, DefaultError;
+def note_in_class_initializer_float_type_cxx11 : Note<"add 'constexpr'">;
def err_in_class_initializer_literal_type : Error<
"in-class initializer for static data member of type %0 requires "
"'constexpr' specifier">;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 29 16:26:08 2013
@@ -7203,15 +7203,12 @@ void Sema::AddInitializerToDecl(Decl *Re
// In C++98, this is a GNU extension. In C++11, it is not, but we support
// it anyway and provide a fixit to add the 'constexpr'.
if (getLangOpts().CPlusPlus11) {
- SemaDiagnosticBuilder D = Diag(VDecl->getLocation(),
- diag::ext_in_class_initializer_float_type_cxx11);
- D << DclT << Init->getSourceRange();
- if (Diags.getDiagnosticLevel(diag::warn_initializer_out_of_order,
- VDecl->getLocation()) >=
- DiagnosticsEngine::Error) {
- D << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr ");
- VDecl->setConstexpr(true);
- }
+ Diag(VDecl->getLocation(),
+ diag::ext_in_class_initializer_float_type_cxx11)
+ << DclT << Init->getSourceRange();
+ Diag(VDecl->getLocStart(),
+ diag::note_in_class_initializer_float_type_cxx11)
+ << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr ");
} else {
Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type)
<< DclT << Init->getSourceRange();
Modified: cfe/trunk/test/CXX/class/class.static/class.static.data/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.static/class.static.data/p3.cpp?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.static/class.static.data/p3.cpp (original)
+++ cfe/trunk/test/CXX/class/class.static/class.static.data/p3.cpp Tue Jan 29 16:26:08 2013
@@ -13,7 +13,7 @@ struct S {
static const int d2 = 0;
static constexpr double e = 0.0; // ok
- static const double f = 0.0; // expected-error {{requires 'constexpr' specifier}}
+ static const double f = 0.0; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
static char *const g = 0; // expected-error {{requires 'constexpr' specifier}}
static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}}
};
Modified: cfe/trunk/test/CXX/class/class.union/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/p2-0x.cpp?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.union/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/class/class.union/p2-0x.cpp Tue Jan 29 16:26:08 2013
@@ -7,7 +7,7 @@ union U1 {
static const int k2 = k1;
static int k3 = k2; // expected-error {{non-const static data member must be initialized out of line}}
static constexpr double k4 = k2;
- static const double k5 = k4; // expected-error {{requires 'constexpr' specifier}}
+ static const double k5 = k4; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
int n[k1 + 3];
};
Modified: cfe/trunk/test/SemaCXX/cxx0x-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-class.cpp?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-class.cpp Tue Jan 29 16:26:08 2013
@@ -20,8 +20,8 @@ namespace rdar8367341 {
float foo(); // expected-note {{here}}
struct A {
- static const float x = 5.0f; // expected-warning {{requires 'constexpr'}}
- static const float y = foo(); // expected-warning {{requires 'constexpr'}}
+ static const float x = 5.0f; // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}}
+ static const float y = foo(); // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}}
static constexpr float x2 = 5.0f;
static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
};
Modified: cfe/trunk/test/SemaCXX/warn-static-const-float.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-static-const-float.cpp?rev=173841&r1=173840&r2=173841&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-static-const-float.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-static-const-float.cpp Tue Jan 29 16:26:08 2013
@@ -10,9 +10,10 @@
#if NONE
// expected-no-diagnostics
#elif ERR
-// expected-error at 19 {{in-class initializer for static data member of type 'const double' requires 'constexpr' specifier}}
+// expected-error at 20 {{in-class initializer for static data member of type 'const double' requires 'constexpr' specifier}}
+// expected-note at 20 {{add 'constexpr'}}
#elif EXT
-// expected-warning at 19 {{in-class initializer for static data member of type 'const double' is a GNU extension}}
+// expected-warning at 20 {{in-class initializer for static data member of type 'const double' is a GNU extension}}
#endif
struct X {
More information about the cfe-commits
mailing list