aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2018-11-25 20:38:00 -0500
committerSandra Loosemore <sandra@gcc.gnu.org>2018-11-25 20:38:00 -0500
commit721b7fd257f4dead1c14c48a1256c3ae46b7f36a (patch)
tree7b849cdcf23f619089f5167092a2ea0169df6a9a /gcc
parent47e53bb6464a51c879a2258771cae4d9c51cbe2b (diff)
downloadgcc-721b7fd257f4dead1c14c48a1256c3ae46b7f36a.zip
gcc-721b7fd257f4dead1c14c48a1256c3ae46b7f36a.tar.gz
gcc-721b7fd257f4dead1c14c48a1256c3ae46b7f36a.tar.bz2
re PR web/79738 (Documentation for __attribute__((const)) slightly misleading)
2018-11-25 Sandra Loosemore <sandra@codesourcery.com> PR web/79738 gcc/ * doc/extend.texi (Common Function Attributes): Clarify that functions with "const" attribute can read const global variables. From-SVN: r266445
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/doc/extend.texi15
2 files changed, 15 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 25e7571..f5c73fc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-25 Sandra Loosemore <sandra@codesourcery.com>
+
+ PR web/79738
+ * doc/extend.texi (Common Function Attributes): Clarify that
+ functions with "const" attribute can read const global variables.
+
2018-11-26 Alan Modra <amodra@gmail.com>
* config/rs6000/rs6000.h (OBJECT_PEF, TARGET_MACOS): Delete.
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 3639254..4e8be5b 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2521,11 +2521,13 @@ are automatically detected and this attribute is ignored.
Many functions do not examine any values except their arguments, and
have no effects except to return a value. Calls to such functions lend
themselves to optimization such as common subexpression elimination.
+The presence of the @code{const} attribute on a function declaration
+allows GCC to emit more efficient code for some calls to the function.
+
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 declaration allows GCC to emit more efficient
-code for some calls to the function. Decorating the same function with
+definition than the similar @code{pure} attribute below because it
+additionally prohibits the function from reading memory except for
+constant global variables. Decorating the same function with
both the @code{const} and the @code{pure} attribute is diagnosed.
@cindex pointer arguments
@@ -3315,8 +3317,9 @@ depending on volatile memory or other system resource, that may change between
two consecutive calls (such as @code{feof} in a multithreading environment).
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
+a function's definition than the @code{const} attribute: @code{pure}
+allows the function to read any non-volatile memory, not just
+constant 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