mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-08 08:54:58 +00:00
Add a standard for control-flow unreachable assertions in functions that return
values, so as to avoid warnings on some platforms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51831 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
48fb19a270
commit
f4408e8c3e
@ -623,6 +623,29 @@ assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!"
|
|||||||
|
|
||||||
<p>You get the idea...</p>
|
<p>You get the idea...</p>
|
||||||
|
|
||||||
|
<p>Please be aware when adding assert statements that not all compilers are aware of
|
||||||
|
the semantics of the assert. In some places, asserts are used to indicate a piece of
|
||||||
|
code that should not be reached. These are typically of the form:</p>
|
||||||
|
|
||||||
|
<div class="doc_code">
|
||||||
|
<pre>
|
||||||
|
assert(0 && "Some helpful error message");
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>When used in a function that returns a value, they should be followed with a return
|
||||||
|
statement and a comment indicating that this line is never reached. This will prevent
|
||||||
|
a compiler which is unable to deduce that the assert statement never returns from
|
||||||
|
generating a warning.</p>
|
||||||
|
|
||||||
|
<div class="doc_code">
|
||||||
|
<pre>
|
||||||
|
assert(0 && "Some helpful error message");
|
||||||
|
// Not reached
|
||||||
|
return 0;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
|
Loading…
Reference in New Issue
Block a user