[llvm-branch-commits] [cfe-branch] r197319 - Merging r197305:

Bill Wendling isanbard at gmail.com
Fri Dec 13 23:59:18 PST 2013


Author: void
Date: Sat Dec 14 01:59:17 2013
New Revision: 197319

URL: http://llvm.org/viewvc/llvm-project?rev=197319&view=rev
Log:
Merging r197305:
------------------------------------------------------------------------
r197305 | rsmith | 2013-12-13 19:18:05 -0800 (Fri, 13 Dec 2013) | 7 lines

PR18246: When performing template argument deduction to decide which template
is specialized by an explicit specialization, start from the first declaration
in case we've got a member of a class template (redeclarations might not number
the template parameters the same way).

Our recover here is still far from ideal.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
    cfe/branches/release_34/test/SemaTemplate/explicit-specialization-member.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec 14 01:59:17 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195495,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196143,196145,196153,196189-196192,196198-196199,196206,196208-196209,196211,196215,196359-196362,196370,196387,196423,196454,196456,196459,196488,196532-196533,196535,196538,196588,196593,196599,196612,196630,196658,196712,196720,196724,196771,196852,196957,196995,197022,197120
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195495,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196143,196145,196153,196189-196192,196198-196199,196206,196208-196209,196211,196215,196359-196362,196370,196387,196423,196454,196456,196459,196488,196532-196533,196535,196538,196588,196593,196599,196612,196630,196658,196712,196720,196724,196771,196852,196957,196995,197022,197120,197305
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaTemplate.cpp?rev=197319&r1=197318&r2=197319&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaTemplate.cpp Sat Dec 14 01:59:17 2013
@@ -6523,9 +6523,9 @@ bool Sema::CheckFunctionTemplateSpeciali
       // FIXME: It is somewhat wasteful to build
       TemplateDeductionInfo Info(FailedCandidates.getLocation());
       FunctionDecl *Specialization = 0;
-      if (TemplateDeductionResult TDK
-            = DeduceTemplateArguments(FunTmpl, ExplicitTemplateArgs, FT,
-                                      Specialization, Info)) {
+      if (TemplateDeductionResult TDK = DeduceTemplateArguments(
+              cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
+              ExplicitTemplateArgs, FT, Specialization, Info)) {
         // Template argument deduction failed; record why it failed, so
         // that we can provide nifty diagnostics.
         FailedCandidates.addCandidate()

Modified: cfe/branches/release_34/test/SemaTemplate/explicit-specialization-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaTemplate/explicit-specialization-member.cpp?rev=197319&r1=197318&r2=197319&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaTemplate/explicit-specialization-member.cpp (original)
+++ cfe/branches/release_34/test/SemaTemplate/explicit-specialization-member.cpp Sat Dec 14 01:59:17 2013
@@ -28,3 +28,22 @@ namespace PR12331 {
   };
   template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}}
 }
+
+namespace PR18246 {
+  template<typename T>
+  class Baz {
+  public:
+    template<int N> void bar();
+  };
+
+  template<typename T>
+  template<int N>
+  void Baz<T>::bar() {
+  }
+
+  // FIXME: Don't suggest the 'template<>' correction here, because this cannot
+  // be an explicit specialization.
+  template<typename T>
+  void Baz<T>::bar<0>() { // expected-error {{requires 'template<>'}}
+  }
+}





More information about the llvm-branch-commits mailing list