<div dir="ltr">Reverted in r282555.<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 27, 2016 at 3:44 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">It looks like this will reject valid code, such as:<div><br></div><div>template<bool B> struct X {</div><div>  using T = typename std::conditional<B, const X&, X&&>::type;</div><div>  X();</div><div>  X(T) = default; // either copyable or moveable, depending on B</div><div>};</div><div><br><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-">On Tue, Sep 27, 2016 at 3:28 PM, Richard Trieu via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: rtrieu<br>
Date: Tue Sep 27 17:28:59 2016<br>
New Revision: 282547<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=282547&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=282547&view=rev</a><br>
Log:<br>
Fix defaulted member functions for templated classes.<br>
<br>
In some cases, non-special member functions were being marked as being defaulted<br>
in templated classes.  This can cause interactions with later code that expects<br>
the default function to be one of the specific member functions.</blockquote><div><br></div></span><div>If later code is assuming that a defaulted member of a dependent class is a specific special member function, it is wrong; we should put the fix there instead of here.</div><div><div class="gmail-h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Fix the check<br>
so that templated class members are checked the same way as non-templated class<br>
members are.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDeclCXX<wbr>.cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-d<wbr>efaulted-functions.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=282547&r1=282546&r2=282547&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaD<wbr>eclCXX.cpp?rev=282547&r1=28254<wbr>6&r2=282547&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX<wbr>.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX<wbr>.cpp Tue Sep 27 17:28:59 2016<br>
@@ -13850,12 +13850,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S<br>
   CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl<wbr>>(Dcl);<br>
<br>
   if (MD) {<br>
-    if (MD->getParent()->isDependentT<wbr>ype()) {<br>
-      MD->setDefaulted();<br>
-      MD->setExplicitlyDefaulted();<br>
-      return;<br>
-    }<br>
-<br>
     CXXSpecialMember Member = getSpecialMember(MD);<br>
     if (Member == CXXInvalid) {<br>
       if (!MD->isInvalidDecl())<br>
@@ -13866,6 +13860,8 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S<br>
     MD->setDefaulted();<br>
     MD->setExplicitlyDefaulted();<br>
<br>
+    if (MD->getParent()->isDependentT<wbr>ype()) return;<br>
+<br>
     // If this definition appears within the record, do the checking when<br>
     // the record is complete.<br>
     const FunctionDecl *Primary = MD;<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx0x-d<wbr>efaulted-functions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=282547&r1=282546&r2=282547&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>cxx0x-defaulted-functions.cpp?<wbr>rev=282547&r1=282546&r2=<wbr>282547&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-d<wbr>efaulted-functions.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-d<wbr>efaulted-functions.cpp Tue Sep 27 17:28:59 2016<br>
@@ -208,3 +208,31 @@ int fn() {<br>
   t = true;<br>
 }<br>
 }<br>
+<br>
+namespace templated_class {<br>
+template <typename T><br>
+class X {<br>
+    X() = default;<br>
+    X(const X&) = default;<br>
+    X(X&&) = default;<br>
+    X &operator=(const X&) = default;<br>
+    X &operator=(X&&) = default;<br>
+    ~X() = default;<br>
+<br>
+    X(T) = default;  // expected-error {{only special member functions may be defaulted}}<br>
+    void Run() = default;  // expected-error {{only special member functions may be defaulted}}<br>
+<br>
+  };<br>
+  template <typename T><br>
+  X<T>::X() = default; // expected-error {{definition of explicitly defaulted}}<br>
+  template <typename T><br>
+  X<T>::X(const X<T>&) = default; // expected-error {{definition of explicitly defaulted}}<br>
+  template <typename T><br>
+  X<T>::X(X<T>&&) = default; // expected-error {{definition of explicitly defaulted}}<br>
+  template <typename T><br>
+  X<T> &X<T>::operator=(const X<T>&) = default; // expected-error {{definition of explicitly defaulted}}<br>
+  template <typename T><br>
+  X<T> &X<T>::operator=(X<T>&&) = default; // expected-error {{definition of explicitly defaulted}}<br>
+  template <typename T><br>
+  X<T>::~X() = default; // expected-error {{definition of explicitly defaulted}}<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div></div>
</blockquote></div><br></div></div>