From: Douglas Gregor Date: Thu, 29 Apr 2010 04:55:13 +0000 (+0000) Subject: It turns out that we *can* end up having to display template argument X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77e2c67411084c47b1cf511a191b31adf38662ba;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102595 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 731836b0b1..ad6cc2f4c8 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -5518,8 +5518,15 @@ Sema::getTemplateArgumentBindingsText(const TemplateParameterList *Params, } case TemplateArgument::Expression: { - assert(false && "No expressions in deduced template arguments!"); - Result += ""; + // 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; } diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index 7b83ff9194..d351eb4588 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -193,3 +193,13 @@ namespace EntityReferenced { typedef X::f> x; // expected-note{{in instantiation of}} } } + +namespace PR6964 { + template // 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 + struct as_nview // expected-note{{while checking a default template argument used here}} + { }; +}