diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-09-29 23:18:34 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-09-29 23:18:34 +0000 |
commit | 947be1941e9a1d4233116f51a45799d3904d4231 (patch) | |
tree | 14204fef2feaf0222977986f4f66cccbab889071 /lib/Sema/SemaDecl.cpp | |
parent | 0f32caff4dc351719ca3362d95f859d72fdd6f1b (diff) |
Mark the ExtWarn for in-class initialization of static const float members as a GNU extension. Don't extend the scope of this extension to all literal types in C++0x mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d34d710cc7..7bb3aa1511 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5875,13 +5875,6 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, VDecl->setInvalidDecl(); } - // Suggest adding 'constexpr' in C++0x for literal types. - } else if (getLangOptions().CPlusPlus0x && T->isLiteralType()) { - Diag(VDecl->getLocation(), diag::ext_in_class_initializer_literal_type) - << T << Init->getSourceRange() - << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr "); - VDecl->setConstexpr(true); - // We allow floating-point constants as an extension. } else if (T->isFloatingType()) { // also permits complex, which is ok Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type) @@ -5893,6 +5886,14 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, << Init->getSourceRange(); VDecl->setInvalidDecl(); } + + // Suggest adding 'constexpr' in C++0x for literal types. + } else if (getLangOptions().CPlusPlus0x && T->isLiteralType()) { + Diag(VDecl->getLocation(), diag::err_in_class_initializer_literal_type) + << T << Init->getSourceRange() + << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr "); + VDecl->setConstexpr(true); + } else { Diag(VDecl->getLocation(), diag::err_in_class_initializer_bad_type) << T << Init->getSourceRange(); |