[cfe-commits] r138735 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
Jeffrey Yasskin
jyasskin at google.com
Mon Aug 29 08:59:37 PDT 2011
Author: jyasskin
Date: Mon Aug 29 10:59:37 2011
New Revision: 138735
URL: http://llvm.org/viewvc/llvm-project?rev=138735&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=138735&r1=138734&r2=138735&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Aug 29 10:59:37 2011
@@ -5168,15 +5168,15 @@
: 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);
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp?rev=138735&r1=138734&r2=138735&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp Mon Aug 29 10:59:37 2011
@@ -160,3 +160,13 @@
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}}
+}
More information about the cfe-commits
mailing list