8302124: HotSpot Style Guide should permit noreturn attribute

Reviewed-by: dcubed, iveresov, dholmes, tschatzl, jwaters, kvn
This commit is contained in:
Kim Barrett 2023-02-28 01:59:03 +00:00
parent bca60f4767
commit 14a014d430
2 changed files with 52 additions and 12 deletions

View File

@ -82,6 +82,7 @@ id="toc-uniform-initialization">Uniform Initialization</a></li>
id="toc-local-function-objects">Local Function Objects</a></li>
<li><a href="#inheriting-constructors"
id="toc-inheriting-constructors">Inheriting constructors</a></li>
<li><a href="#attributes" id="toc-attributes">Attributes</a></li>
<li><a href="#additional-permitted-features"
id="toc-additional-permitted-features">Additional Permitted
Features</a></li>
@ -1057,6 +1058,31 @@ using C++17 or later. It is also enabled by default for
C++11/14, as the change is considered a Defect Report that applies to
those versions. Earlier versions of gcc don't have that option, and
other supported compilers may not have anything similar.</p>
<h3 id="attributes">Attributes</h3>
<p>The use of some attributes (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf">n2761</a>)
(listed below) is permitted. (Note that some of the attributes defined
in that paper didn't make it into the final specification.)</p>
<p>Attributes are syntactically permitted in a broad set of locations,
but specific attributes are only permitted in a subset of those
locations. In some cases an attribute that appertains to a given element
may be placed in any of several locations with the same meaning. In
those cases HotSpot has a preferred location.</p>
<ul>
<li>An attribute that appertains to a function is placed at the
beginning of the function's declaration, rather than between the
function name and the parameter list.</li>
</ul>
<p>Only the following attributes are permitted:</p>
<ul>
<li><code>[[noreturn]]</code></li>
</ul>
<p>The following attributes are expressly forbidden:</p>
<ul>
<li><code>[[carries_dependency]]</code> - Related to
<code>memory_order_consume</code>.</li>
<li><code>[[deprecated]]</code> - Not relevant in HotSpot code.</li>
</ul>
<h3 id="additional-permitted-features">Additional Permitted
Features</h3>
<ul>
@ -1149,9 +1175,6 @@ initialization or destruction. Initialization order problems can be
difficult to deal with and lead to surprises, as can destruction
ordering. HotSpot doesn't generally try to cleanup on exit, and running
destructors at exit can also lead to problems.</p></li>
<li><p><code>[[deprecated]]</code> attribute (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html">n3760</a>)
— Not relevant in HotSpot code.</p></li>
<li><p>Avoid most operator overloading, preferring named functions. When
operator overloading is used, ensure the semantics conform to the normal
expected behavior of the operation.</p></li>
@ -1171,8 +1194,6 @@ href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm">n2541</
href="https://isocpp.org/files/papers/N3651.pdf">n3651</a>)</p></li>
<li><p>Member initializers and aggregates (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3653.html">n3653</a>)</p></li>
<li><p><code>[[noreturn]]</code> attribute (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf">n2761</a>)</p></li>
<li><p>Rvalue references and move semantics</p></li>
</ul>
</body>

View File

@ -1054,6 +1054,32 @@ and other supported compilers may not have anything similar.
[p0136r1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0136r1.html
"p0136r1"
### Attributes
The use of some attributes
([n2761](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf))
(listed below) is permitted. (Note that some of the attributes defined in
that paper didn't make it into the final specification.)
Attributes are syntactically permitted in a broad set of locations, but
specific attributes are only permitted in a subset of those locations. In
some cases an attribute that appertains to a given element may be placed in
any of several locations with the same meaning. In those cases HotSpot has a
preferred location.
* An attribute that appertains to a function is placed at the beginning of the
function's declaration, rather than between the function name and the parameter
list.
Only the following attributes are permitted:
* `[[noreturn]]`
The following attributes are expressly forbidden:
* `[[carries_dependency]]` - Related to `memory_order_consume`.
* `[[deprecated]]` - Not relevant in HotSpot code.
### Additional Permitted Features
* `constexpr`
@ -1153,10 +1179,6 @@ difficult to deal with and lead to surprises, as can destruction
ordering. HotSpot doesn't generally try to cleanup on exit, and
running destructors at exit can also lead to problems.
* `[[deprecated]]` attribute
([n3760](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html)) &mdash;
Not relevant in HotSpot code.
* Avoid most operator overloading, preferring named functions. When
operator overloading is used, ensure the semantics conform to the
normal expected behavior of the operation.
@ -1181,9 +1203,6 @@ features that have not yet been discussed.
* Member initializers and aggregates
([n3653](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3653.html))
* `[[noreturn]]` attribute
([n2761](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf))
* Rvalue references and move semantics
[ADL]: https://en.cppreference.com/w/cpp/language/adl