]> granicus.if.org Git - clang/commitdiff
When finalizing a function template specialization following template
authorDouglas Gregor <dgregor@apple.com>
Tue, 12 Oct 2010 18:51:08 +0000 (18:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 12 Oct 2010 18:51:08 +0000 (18:51 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116327 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateDeduction.cpp
test/CXX/temp/temp.arg/temp.arg.type/p2.cpp

index f3ffa716f1b90c33a00439e5772f4534fc81384d..6237610c098d09d0da5b82ca86d9f02ab0b936f0 100644 (file)
@@ -1018,7 +1018,7 @@ FinishTemplateArgumentDeduction(Sema &S,
   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 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
   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;
       }
index 0384aa70fa002604a4411f91746fc725ea644c1d..5c44ccb63532099f0c3184af08c37b9ad47ee21d 100644 (file)
@@ -10,3 +10,12 @@ template<typename T> struct B {
 };
 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'}}
+}
+