Commit 721b7fd2 by Sandra Loosemore Committed by Sandra Loosemore

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
parent 47e53bb6
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> 2018-11-26 Alan Modra <amodra@gmail.com>
* config/rs6000/rs6000.h (OBJECT_PEF, TARGET_MACOS): Delete. * config/rs6000/rs6000.h (OBJECT_PEF, TARGET_MACOS): Delete.
...@@ -2521,11 +2521,13 @@ are automatically detected and this attribute is ignored. ...@@ -2521,11 +2521,13 @@ are automatically detected and this attribute is ignored.
Many functions do not examine any values except their arguments, and Many functions do not examine any values except their arguments, and
have no effects except to return a value. Calls to such functions lend have no effects except to return a value. Calls to such functions lend
themselves to optimization such as common subexpression elimination. 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 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
the function from reading global variables. Consequently, the presence of additionally prohibits the function from reading memory except for
the attribute on a function declaration allows GCC to emit more efficient constant global variables. 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.
@cindex pointer arguments @cindex pointer arguments
...@@ -3315,8 +3317,9 @@ depending on volatile memory or other system resource, that may change between ...@@ -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). two consecutive calls (such as @code{feof} in a multithreading environment).
The @code{pure} attribute imposes similar but looser restrictions on 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 definition than the @code{const} attribute: @code{pure}
function to read global variables. Decorating the same function with 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. both the @code{pure} and the @code{const} attribute is diagnosed.
Because a @code{pure} function cannot have any side effects it does not 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 make sense for such a function to return @code{void}. Declaring such
......
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