r188409 - Bug fix: note diagnosis on expression narrowing should say "variable template" instead of "static data member" when appropriate

Larisse Voufo lvoufo at google.com
Wed Aug 14 13:15:03 PDT 2013


Author: lvoufo
Date: Wed Aug 14 15:15:02 2013
New Revision: 188409

URL: http://llvm.org/viewvc/llvm-project?rev=188409&view=rev
Log:
Bug fix: note diagnosis on expression narrowing should say "variable template" instead of "static data member" when appropriate

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=188409&r1=188408&r2=188409&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug 14 15:15:02 2013
@@ -3173,6 +3173,8 @@ def note_function_template_spec_here : N
   "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<

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=188409&r1=188408&r2=188409&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed Aug 14 15:15:02 2013
@@ -524,7 +524,9 @@ void Sema::PrintInstantiationStack() {
           << Active->InstantiationRange;
       } else if (VarDecl *VD = dyn_cast<VarDecl>(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<EnumDecl>(D)) {

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp?rev=188409&r1=188408&r2=188409&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp Wed Aug 14 15:15:02 2013
@@ -126,7 +126,7 @@ namespace odr_tmpl {
   }
 #endif
   
-}  
+}
 
 namespace explicit_instantiation {
   template<typename T> 
@@ -321,6 +321,15 @@ namespace explicit_specialization {
   }
 }
 
+namespace narrowing {
+  template<typename T> T v = {1234};  // expected-warning {{implicit conversion from 'int' to 'char' changes value from 1234 to}}
+#ifdef CXX11
+  // expected-error at -2 {{constant expression evaluates to 1234 which cannot be narrowed to type 'char'}}\
+  // expected-note at -2 {{override this message by inserting an explicit cast}}
+#endif
+  int k = v<char>;        // expected-note {{in instantiation of variable template specialization 'narrowing::v<char>' requested here}}
+}
+
 namespace use_in_structs {
   // TODO:
 }





More information about the cfe-commits mailing list