]> granicus.if.org Git - clang/commitdiff
Bug fix: note diagnosis on expression narrowing should say "variable template" instea...
authorLarisse Voufo <lvoufo@google.com>
Wed, 14 Aug 2013 20:15:02 +0000 (20:15 +0000)
committerLarisse Voufo <lvoufo@google.com>
Wed, 14 Aug 2013 20:15:02 +0000 (20:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188409 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d35680848be44d94249d77ed57bd4e6c6b6f8461..d50b7fca1b5c9546e0eaf0eed917d14c3ecdc260 100644 (file)
@@ -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<
index 83c4c115fab264f1ff034fdc8879c64f1fe7780f..9f84fc665b1fc850b6f047b8acdc6b81c97378df 100644 (file)
@@ -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)) {
index 82e3c116aad8c676b10904f40bd5ed425072ffde..61fccac038bb12e36be27d857b3a8aa37bdb1ca7 100644 (file)
@@ -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@-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<char>;        // expected-note {{in instantiation of variable template specialization 'narrowing::v<char>' requested here}}
+}
+
 namespace use_in_structs {
   // TODO:
 }