[cfe-commits] r102595 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/temp_arg_nontype.cpp

Douglas Gregor dgregor at apple.com
Wed Apr 28 21:55:13 PDT 2010


Author: dgregor
Date: Wed Apr 28 23:55:13 2010
New Revision: 102595

URL: http://llvm.org/viewvc/llvm-project?rev=102595&view=rev
Log:
It turns out that we *can* end up having to display template argument
bindings when the template argument is still an expression; it happens
while checking the template arguments of a class template partial
specializations. Fixes PR6964.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=102595&r1=102594&r2=102595&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Apr 28 23:55:13 2010
@@ -5518,8 +5518,15 @@
       }
         
       case TemplateArgument::Expression: {
-        assert(false && "No expressions in deduced template arguments!");
-        Result += "<expression>";
+        // FIXME: This is non-optimal, since we're regurgitating the
+        // expression we were given.
+        std::string Str; 
+        {
+          llvm::raw_string_ostream OS(Str);
+          Args[I].getAsExpr()->printPretty(OS, Context, 0,
+                                           Context.PrintingPolicy);
+        }
+        Result += Str;
         break;
       }
         

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=102595&r1=102594&r2=102595&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Wed Apr 28 23:55:13 2010
@@ -193,3 +193,13 @@
     typedef X<int*, Y<int*>::f> x; // expected-note{{in instantiation of}}
   }
 }
+
+namespace PR6964 {
+  template <typename ,int, int = 9223372036854775807L > // expected-warning 2{{non-type template argument value '9223372036854775807' truncated to '-1' for template parameter of type 'int'}} \
+  // expected-note 2{{template parameter is declared here}}
+  struct as_nview { };
+
+  template <typename Sequence, int I0> 
+  struct as_nview<Sequence, I0>  // expected-note{{while checking a default template argument used here}}
+  { };
+}





More information about the cfe-commits mailing list