aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-04-03 17:35:14 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-04-03 11:35:14 -0600
commitb4231bf26e398d6799facf6bc93caeefd7d16d5a (patch)
tree03cce51da066adc346384d5c7ba897532758fa49 /gcc
parent92c59b7466a8caeab26f239ba4b004e68700d92e (diff)
downloadgcc-b4231bf26e398d6799facf6bc93caeefd7d16d5a.zip
gcc-b4231bf26e398d6799facf6bc93caeefd7d16d5a.tar.gz
gcc-b4231bf26e398d6799facf6bc93caeefd7d16d5a.tar.bz2
extend.texi (Common Function Attributes): Clarify.
gcc/ChangeLog: * doc/extend.texi (Common Function Attributes): Clarify. (const attribute): Likewise. (pure attribute): Likewise. From-SVN: r259041
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/doc/extend.texi17
2 files changed, 18 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index efd155e..82f6155 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR target/85169
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cb0d9c0..6296326 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2275,8 +2275,11 @@ on a declaration, followed by an attribute specification inside double
parentheses. You can specify multiple attributes in a declaration by
separating them by commas within the double parentheses or by
immediately following an attribute declaration with another attribute
-declaration. @xref{Attribute Syntax}, for the exact rules on
-attribute syntax and placement.
+declaration. @xref{Attribute Syntax}, for the exact rules on attribute
+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
variable declarations (@pxref{Variable Attributes}),
@@ -2499,7 +2502,7 @@ themselves to optimization such as common subexpression elimination.
The @code{const} attribute imposes greater restrictions on a function's
definition than the similar @code{pure} attribute below because it prohibits
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
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
pointed to must @emph{not} be declared @code{const}. Likewise, a
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
-return @code{void}.
+@code{const}. Because a @code{const} 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 constructor
@itemx destructor
@@ -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
function to read global variables. Decorating the same function with
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
@cindex @code{returns_nonnull} function attribute