<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Dec 3, 2013, at 10:31 AM, Arthur O'Dwyer <<a href="mailto:arthur.j.odwyer@gmail.com">arthur.j.odwyer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Tue, Dec 3, 2013 at 9:42 AM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><blockquote type="cite">On Dec 3, 2013, at 9:35 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><blockquote type="cite">On Dec 3, 2013, at 9:10 , Fariborz Jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br></blockquote><br>Author: fjahanian<br>Date: Tue Dec  3 11:10:08 2013<br>New Revision: 196296<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=196296&view=rev">http://llvm.org/viewvc/llvm-project?rev=196296&view=rev</a><br>Log:<br>Issue diagnostic when constructor or destructor<br>return void expression. // <a href="rdar://15366494">rdar://15366494</a><br>pr17759.<br></blockquote>[...]<br><blockquote type="cite">+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec  3 11:10:08<br>2013<br>@@ -6426,6 +6426,8 @@ def ext_return_has_void_expr : Extension<br>def err_return_init_list : Error<<br> "%select{void function|void method|constructor|destructor}1 %0 "<br> "must not return a value">;<br>+def err_ctor_dtor_returns_void : Error<<br>+  "%select{constructor|destructor}1 %0 must not return void expression">;<br></blockquote><br><br>IMO, the diagnostic's wording should be the same for<br><br>    int foo();<br>    struct C1 { C1() { return foo(); } };  // error: constructor 'C'<br>should not return a value [-Wreturn-type]<br><br>and<br><br>    void bar();<br>    struct C2 { C2() { return bar(); } };  // error: constructor 'C'<br>must not return void expression [-Wreturn-type]<br></blockquote><div><br></div>Problem I faced is that under an extension warning flag, one can return a non-void </div><div>expression in a constructor/destructor. But returning a void expression is always an error.</div><div>So, consolidating both cases into one diagnostic is not feasible. Please look at</div><div>definition of <span style="font-family: Menlo; font-size: 11px;">ext_return_has_expr vs </span>err_ctor_dtor_returns_void</div><div><br></div><div>- Fariborz</div><div><br><blockquote type="cite"><br>I don't see any significant difference between the two cases, and it<br>doesn't seem like they should have two different diagnostics issued<br>along two different (and convoluted and difficult-to-maintain)<br>codepaths. A compromise would be to %select a user-friendly<br>clarification in the case that we're about to issue the diagnostic and<br>we notice that the returned expression is of type (cv-qualified) void:<br><br>    void bar();<br>    struct C2 { C2() { return bar(); } };  // error: constructor 'C'<br>should not return a value (not even of type 'void') [-Wreturn-type]<br><br>my $.02,<br>–Arthur<br></blockquote></div><br></body></html>