diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2011-08-29 15:59:37 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2011-08-29 15:59:37 +0000 |
commit | 9906149972906e340f512a60f72a8676748f24d8 (patch) | |
tree | eaf894139e1aab228a5aca8303148fc89e88b0f3 | |
parent | 7daa846b84bf9bc176fee967996ca2dfed4fb1f5 (diff) |
Print 'int' instead of 'const int' in the narrowing conversion error, since the
qualification of a type doesn't affect whether a conversion is a narrowing
conversion.
This doesn't work in template cases because SubstTemplateTypeParmType gets in
the way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138735 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaInit.cpp | 6 | ||||
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 2d47cda0e0..7a6134453b 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -5168,15 +5168,15 @@ static void DiagnoseNarrowingInInitList( : diag::warn_init_list_constant_narrowing) << InitE->getSourceRange() << ConstantValue - << EntityType; + << EntityType.getLocalUnqualifiedType(); } else S.Diag(InitE->getLocStart(), S.getLangOptions().CPlusPlus0x && !S.getLangOptions().Microsoft ? diag::err_init_list_variable_narrowing : diag::warn_init_list_variable_narrowing) << InitE->getSourceRange() - << InitE->getType() - << EntityType; + << InitE->getType().getLocalUnqualifiedType() + << EntityType.getLocalUnqualifiedType(); llvm::SmallString<128> StaticCast; llvm::raw_svector_ostream OS(StaticCast); diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp index c7f61fbd18..be47cb8fe8 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp @@ -160,3 +160,13 @@ void test_template() { maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}} maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}} } + + +// We don't want qualifiers on the types in the diagnostic. + +void test_qualifiers(int i) { + const int j = i; + struct {const unsigned char c;} c1 = {j}; // expected-error {{from type 'int' to 'unsigned char' in}} expected-note {{override}} + // Template arguments make it harder to avoid printing qualifiers: + Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{override}} +} |