[cfe-commits] r116327 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.arg/temp.arg.type/p2.cpp

Douglas Gregor dgregor at apple.com
Tue Oct 12 11:51:08 PDT 2010


Author: dgregor
Date: Tue Oct 12 13:51:08 2010
New Revision: 116327

URL: http://llvm.org/viewvc/llvm-project?rev=116327&view=rev
Log:
When finalizing a function template specialization following template
argument deduction, make sure to check the correctness of deduced template
type arguments (which we had previously skipped) along with other
kinds of template arguments. This fixes part of PR6784, but we're
still swallowing the extension warning about unnamed/local template
arguments.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=116327&r1=116326&r2=116327&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Oct 12 13:51:08 2010
@@ -1018,7 +1018,7 @@
   for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
     if (Deduced[I].isNull()) {
       Decl *Param
-      = const_cast<NamedDecl *>(
+        = const_cast<NamedDecl *>(
                                 Partial->getTemplateParameters()->getParam(I));
       Info.Param = makeTemplateParameter(Param);
       return Sema::TDK_Incomplete;
@@ -1383,13 +1383,10 @@
   for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
     NamedDecl *Param = FunctionTemplate->getTemplateParameters()->getParam(I);
     if (!Deduced[I].isNull()) {
-      if (I < NumExplicitlySpecified || 
-          Deduced[I].getKind() == TemplateArgument::Type) {
+      if (I < NumExplicitlySpecified) {
         // We have already fully type-checked and converted this
-        // argument (because it was explicitly-specified) or no
-        // additional checking is necessary (because it's a template
-        // type parameter). Just record the presence of this
-        // parameter.
+        // argument, because it was explicitly-specified. Just record the 
+        // presence of this argument.
         Builder.Append(Deduced[I]);
         continue;
       }

Modified: cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp?rev=116327&r1=116326&r2=116327&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp Tue Oct 12 13:51:08 2010
@@ -10,3 +10,12 @@
 };
 B<function> b; // expected-note{{instantiation of}}
 
+template <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}}
+enum {e};
+
+void test_f0(int n) {
+  int i = f0(0, e); // FIXME: We should get a warning here, at least
+  int vla[n];
+  f0(0, vla); // expected-error{{no matching function for call to 'f0'}}
+}
+





More information about the cfe-commits mailing list