diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-03-29 23:39:39 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-03-29 23:39:39 +0000 |
commit | 1ef28dbcf1a8b72f590f2d73bc204e85605ab605 (patch) | |
tree | b277ffc49cf66ae484eef2bd829bae9ba9a7f0ca /lib/Sema/SemaOverload.cpp | |
parent | 4b81e742c8d23600e4244d69f20322e3535e3d86 (diff) |
Extend -Wc++11-narrowing to cover converted constant expressions as well as braced-initializers. <rdar://problem/11121178>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 661f589099..e1d32056eb 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4808,7 +4808,6 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, // Check for a narrowing implicit conversion. APValue PreNarrowingValue; QualType PreNarrowingType; - bool Diagnosed = false; switch (SCS->getNarrowingKind(Context, Result.get(), PreNarrowingValue, PreNarrowingType)) { case NK_Variable_Narrowing: @@ -4818,16 +4817,18 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, break; case NK_Constant_Narrowing: - Diag(From->getLocStart(), diag::err_cce_narrowing) + Diag(From->getLocStart(), + isSFINAEContext() ? diag::err_cce_narrowing_sfinae : + diag::err_cce_narrowing) << CCE << /*Constant*/1 << PreNarrowingValue.getAsString(Context, PreNarrowingType) << T; - Diagnosed = true; break; case NK_Type_Narrowing: - Diag(From->getLocStart(), diag::err_cce_narrowing) + Diag(From->getLocStart(), + isSFINAEContext() ? diag::err_cce_narrowing_sfinae : + diag::err_cce_narrowing) << CCE << /*Constant*/0 << From->getType() << T; - Diagnosed = true; break; } @@ -4849,10 +4850,6 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, } } - // Only issue one narrowing diagnostic. - if (Diagnosed) - return Result; - // It's not a constant expression. Produce an appropriate diagnostic. if (Notes.size() == 1 && Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) |