]> granicus.if.org Git - clang/commitdiff
Extend the deduced/actual argument type checking of C++
authorDouglas Gregor <dgregor@apple.com>
Fri, 17 Jun 2011 05:31:46 +0000 (05:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 17 Jun 2011 05:31:46 +0000 (05:31 +0000)
[temp.deduct.call]p4 to the deduction performed for 'auto', finishing
the fix for PR9233.

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

lib/Sema/SemaTemplateDeduction.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

index 9612ea777a081c5d1efc8854ae8234c06e63035a..ef5a59a1cd4f0a5fb5fb4971fda06508a12767fc 100644 (file)
@@ -3344,8 +3344,19 @@ Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *Init,
   QualType DeducedType = Deduced[0].getAsType();
   if (DeducedType.isNull())
     return false;
-
+  
   Result = SubstituteAutoTransform(*this, DeducedType).TransformType(Type);
+  
+  // Check that the deduced argument type is compatible with the original
+  // argument type per C++ [temp.deduct.call]p4.
+  if (Result &&
+      CheckOriginalCallArgDeduction(*this, 
+                                    Sema::OriginalCallArg(FuncParam,0,InitType),
+                                    Result->getType())) {
+    Result = 0;
+    return false;
+  }
+
   return true;
 }
 
index 06aeaa690a1a705390b3ecff5cf80a2440d8634e..8b4b70398471b30376cb4af6f678e1f3b3554305 100644 (file)
@@ -54,8 +54,7 @@ void f() {
 
   auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}}
   int **p;
-  // FIXME: due to PR9233, we get the wrong diagnostic here.
-  const auto **fail2(p); // desired-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}} expected-error {{cannot initialize}}
+  const auto **fail2(p); // expected-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}}
 }
 
 struct S {