On Tue, May 10, 2011 at 9:08 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On May 10, 2011, at 8:28 PM, Talin wrote:<br>
> I'm having some trouble getting clang to work with LLVM_ATTRIBUTE_NORETURN defined in Support/Compiler.h. There are several problems:<br>
><br>
> First there's a problem with the macros themselves - AFAIK __declspec(noreturn) has to come at the *front* of the declaration, while __attribute__((noreturn)) has to come *after* it. The usual way of dealing with this is to define a macro which surrounds the declaration like so:<br>


<br>
</div>You can certainly put __attribute__((noreturn)) in the declaration-specifiers of a function.  In fact, I think this is the only supported way of putting an attribute on a function definition (rather than just a declaration).  And it works in GCC, too.<br>


<div class="im"><br>
> So my first question is - has anyone ever tried using these macros under Windows?<br>
<br>
</div>There are public buildbots which compile LLVM and Clang under MSVC.  Also, these macros are used in ErrorHandling.h, which is probably included in a solid 75% of the files in LLVM.<br></blockquote><div><br></div><div>

OK - sorry for going hyperbolic there...</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
> However, there's a more fundamental problem, which is that clang seems to be ignoring the __attribute__((noreturn)) altogether. That is, instead of relying on the above macros, if I just paste the noreturn attribute after my function, I still get "error: control reaches end of non-void function" in many places - errors which I wasn't getting with gcc.<br>


<br>
</div>You'll need to provide a bit more detail than that, because it's certainly working in the test cases I've seen.<br>
<font color="#888888"><br></font></blockquote><div>All right - here's what I have (with much detail omitted):</div><div><br></div><font class="Apple-style-span" face="'courier new', monospace">  class Diagnostics {<br>

  public:<br>    LLVM_ATTRIBUTE_NORETURN void __fail(const char * msg, const char * fname, unsigned lineno);<br>  };<br><br>  Diagnostics diag;<br><br>  std::istream & ArchiveFile::open() {<br>    diag.__fail("Invalid operation: ArchiveFile::open", __FILE__, __LINE__);<br>

  };</font><div><br></div><div>And I get this error:</div><div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">/Users/talin/Projects/tart/trunk/compiler/lib/Common/SourceFile.cpp:110:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]</font></div>

</div><div><br></div></div>And here's the command line:<div><br></div><div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.54">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
</style>


<p class="p1"><font class="Apple-style-span" face="'courier new', monospace">clang -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_GNU_SOURCE -mmacosx-version-min=10.5 -g -I/Users/talin/Projects/tart/build-eclipse -I/Users/talin/Projects/tart/trunk/compiler/include -I/Users/talin/Projects/tart/trunk/linker/include -I/Users/talin/Projects/llvm-inst/include -Wall -Wextra -Werror -Wcast-align -Wpointer-arith -Wno-deprecated -Wno-unused-parameter -fno-rtti -fno-exceptions -fPIC -o CMakeFiles/compiler.dir/lib/Common/SourceFile.cpp.o -c /Users/talin/Projects/tart/trunk/compiler/lib/Common/SourceFile.cpp</font></p>

<br clear="all">-- <br>-- Talin<br>
</div>