Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -3169,6 +3169,8 @@ "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< Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -524,7 +524,9 @@ << 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)) { Index: test/SemaCXX/cxx1y-variable-templates_top_level.cpp =================================================================== --- test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -123,7 +123,7 @@ } #endif -} +} namespace explicit_instantiation { template @@ -318,6 +318,15 @@ } } +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: }