<div dir="ltr"><br><div>Hi Richard,</div><div><br></div><div>Hi all,<br></div><div><br></div><div>This patch fixes PR18746.</div><div><br></div><div><br></div><div><div>Index: lib/Sema/SemaDeclCXX.cpp</div><div>===================================================================</div>

<div>--- lib/Sema/SemaDeclCXX.cpp<span class="" style="white-space:pre">        </span>(revision 205775)</div><div>+++ lib/Sema/SemaDeclCXX.cpp<span class="" style="white-space:pre">      </span>(working copy)</div><div>@@ -1177,12 +1177,19 @@</div>

<div>       // C++1y doesn't require constexpr functions to contain a 'return'</div><div>       // statement. We still do, unless the return type is void, because</div><div>       // otherwise if there's no return statement, the function cannot</div>

<div>-      // be used in a core constant expression.</div><div>+      // be used in a core constant expression. Also, deduced return type</div><div>+      // with no return statements are perfectly legal. For example:</div>

<div>+      // template<typename T> struct X { constexpr auto f() {} };</div><div>+</div><div>       bool OK = getLangOpts().CPlusPlus1y && Dcl->getReturnType()->isVoidType();</div><div>+</div><div>+      if (!getLangOpts().CPlusPlus1y ||</div>

<div>+          !Dcl->getReturnType()->getContainedAutoType()) {</div><div>       Diag(Dcl->getLocation(),</div><div>            OK ? diag::warn_cxx11_compat_constexpr_body_no_return</div><div>               : diag::err_constexpr_body_no_return);</div>

<div>       return OK;</div><div>+      }</div><div>     }</div><div>     if (ReturnStmts.size() > 1) {</div><div>       Diag(ReturnStmts.back(),</div><div>Index: test/SemaCXX/cxx1y-deduced-return-type.cpp</div><div>===================================================================</div>

<div>--- test/SemaCXX/cxx1y-deduced-return-type.cpp<span class="" style="white-space:pre">      </span>(revision 205775)</div><div>+++ test/SemaCXX/cxx1y-deduced-return-type.cpp<span class="" style="white-space:pre">    </span>(working copy)</div>

<div>@@ -261,6 +261,7 @@</div><div> </div><div> namespace Constexpr {</div><div>   constexpr auto f1(int n) { return n; }</div><div>+  template<typename T> struct X { constexpr auto f() {} }; // PR18746</div><div>   struct NonLiteral { ~NonLiteral(); } nl; // expected-note {{user-provided destructor}}</div>

<div>   constexpr auto f2(int n) { return nl; } // expected-error {{return type 'Constexpr::NonLiteral' is not a literal type}}</div><div> }</div></div><div><br></div><div><br></div><div><div>Please if someone could review the same.</div>

</div><div><br></div><div>Thanks,</div><div>Rahul</div></div>