Commit b4231bf2 by Martin Sebor Committed by Martin Sebor

extend.texi (Common Function Attributes): Clarify.

gcc/ChangeLog:

	* doc/extend.texi (Common Function Attributes): Clarify.
	(const attribute): Likewise.
	(pure attribute): Likewise.

From-SVN: r259041
parent 92c59b74
2018-04-03 Martin Sebor <msebor@redhat.com>
* doc/extend.texi (Common Function Attributes): Clarify.
(const attribute): Likewise.
(pure attribute): Likewise.
2018-04-03 Jakub Jelinek <jakub@redhat.com> 2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR target/85169 PR target/85169
......
...@@ -2275,8 +2275,11 @@ on a declaration, followed by an attribute specification inside double ...@@ -2275,8 +2275,11 @@ on a declaration, followed by an attribute specification inside double
parentheses. You can specify multiple attributes in a declaration by parentheses. You can specify multiple attributes in a declaration by
separating them by commas within the double parentheses or by separating them by commas within the double parentheses or by
immediately following an attribute declaration with another attribute immediately following an attribute declaration with another attribute
declaration. @xref{Attribute Syntax}, for the exact rules on declaration. @xref{Attribute Syntax}, for the exact rules on attribute
attribute syntax and placement. syntax and placement. Compatible attribute specifications on distinct
declarations of the same function are merged. An attribute specification
that is not compatible with attributes already applied to a declaration
of the same function is ignored with a warning.
GCC also supports attributes on GCC also supports attributes on
variable declarations (@pxref{Variable Attributes}), variable declarations (@pxref{Variable Attributes}),
...@@ -2499,7 +2502,7 @@ themselves to optimization such as common subexpression elimination. ...@@ -2499,7 +2502,7 @@ themselves to optimization such as common subexpression elimination.
The @code{const} attribute imposes greater restrictions on a function's The @code{const} attribute imposes greater restrictions on a function's
definition than the similar @code{pure} attribute below because it prohibits definition than the similar @code{pure} attribute below because it prohibits
the function from reading global variables. Consequently, the presence of the function from reading global variables. Consequently, the presence of
the attribute on a function declarations allows GCC to emit more efficient the attribute on a function declaration allows GCC to emit more efficient
code for some calls to the function. Decorating the same function with code for some calls to the function. Decorating the same function with
both the @code{const} and the @code{pure} attribute is diagnosed. both the @code{const} and the @code{pure} attribute is diagnosed.
...@@ -2507,8 +2510,9 @@ both the @code{const} and the @code{pure} attribute is diagnosed. ...@@ -2507,8 +2510,9 @@ both the @code{const} and the @code{pure} attribute is diagnosed.
Note that a function that has pointer arguments and examines the data Note that a function that has pointer arguments and examines the data
pointed to must @emph{not} be declared @code{const}. Likewise, a pointed to must @emph{not} be declared @code{const}. Likewise, a
function that calls a non-@code{const} function usually must not be function that calls a non-@code{const} function usually must not be
@code{const}. It does not make sense for a @code{const} function to @code{const}. Because a @code{const} function cannot have any side
return @code{void}. effects it does not make sense for such a function to return @code{void}.
Declaring such a function is diagnosed.
@item constructor @item constructor
@itemx destructor @itemx destructor
...@@ -3218,6 +3222,9 @@ The @code{pure} attribute imposes similar but looser restrictions on ...@@ -3218,6 +3222,9 @@ The @code{pure} attribute imposes similar but looser restrictions on
a function's defintion than the @code{const} attribute: it allows the a function's defintion than the @code{const} attribute: it allows the
function to read global variables. Decorating the same function with function to read global variables. Decorating the same function with
both the @code{pure} and the @code{const} attribute is diagnosed. both the @code{pure} and the @code{const} attribute is diagnosed.
Because a @code{pure} function cannot have any side effects it does not
make sense for such a function to return @code{void}. Declaring such
a function is diagnosed.
@item returns_nonnull @item returns_nonnull
@cindex @code{returns_nonnull} function attribute @cindex @code{returns_nonnull} function attribute
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment