From: Larisse Voufo Date: Wed, 14 Aug 2013 20:15:02 +0000 (+0000) Subject: Bug fix: note diagnosis on expression narrowing should say "variable template" instea... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=933c66b6956e91ef9017b28dd499b317aba83b7b;p=clang Bug fix: note diagnosis on expression narrowing should say "variable template" instead of "static data member" when appropriate git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188409 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index d35680848b..d50b7fca1b 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3173,6 +3173,8 @@ def note_function_template_spec_here : Note< "in instantiation of function template specialization %q0 requested here">; def note_template_static_data_member_def_here : Note< "in instantiation of static data member %q0 requested here">; +def note_template_variable_def_here : Note< + "in instantiation of variable template specialization %q0 requested here">; def note_template_enum_def_here : Note< "in instantiation of enumeration %q0 requested here">; def note_template_type_alias_instantiation_here : Note< diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 83c4c115fa..9f84fc665b 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -524,7 +524,9 @@ void Sema::PrintInstantiationStack() { << Active->InstantiationRange; } else if (VarDecl *VD = dyn_cast(D)) { Diags.Report(Active->PointOfInstantiation, - diag::note_template_static_data_member_def_here) + VD->isStaticDataMember()? + diag::note_template_static_data_member_def_here + : diag::note_template_variable_def_here) << VD << Active->InstantiationRange; } else if (EnumDecl *ED = dyn_cast(D)) { diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 82e3c116aa..61fccac038 100644 --- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -126,7 +126,7 @@ namespace odr_tmpl { } #endif -} +} namespace explicit_instantiation { template @@ -321,6 +321,15 @@ namespace explicit_specialization { } } +namespace narrowing { + template T v = {1234}; // expected-warning {{implicit conversion from 'int' to 'char' changes value from 1234 to}} +#ifdef CXX11 + // expected-error@-2 {{constant expression evaluates to 1234 which cannot be narrowed to type 'char'}}\ + // expected-note@-2 {{override this message by inserting an explicit cast}} +#endif + int k = v; // expected-note {{in instantiation of variable template specialization 'narrowing::v' requested here}} +} + namespace use_in_structs { // TODO: }