summaryrefslogtreecommitdiffstats
path: root/gcc/cp/typeck.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-16 21:00:47 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-16 21:00:47 +0000
commitd1d739f80df91167855aca0e691035811470648f (patch)
treec9fd19db215ed38eb9c7b7d407f8e60c5817857c /gcc/cp/typeck.c
parent1035a676440e88cf45ba92450aaa4b6e3fc4cd20 (diff)
downloadppe42-gcc-d1d739f80df91167855aca0e691035811470648f.tar.gz
ppe42-gcc-d1d739f80df91167855aca0e691035811470648f.zip
* typeck.c (cp_apply_type_quals_to_decl): Expand documentation.
* decl.c (start_decl): Tidy. (start_decl_1): Call cp_apply_type_quals_to_decl after completing the type. (grokdeclarator): Clarify comment. * g++.dg/opt/const-5.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129386 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r--gcc/cp/typeck.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 45988db4597..cfad878f875 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6976,7 +6976,18 @@ cp_has_mutable_p (const_tree type)
return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type);
}
-/* Apply the TYPE_QUALS to the new DECL. */
+/* Set TREE_READONLY and TREE_VOLATILE on DECL as indicated by the
+ TYPE_QUALS. For a VAR_DECL, this may be an optimistic
+ approximation. In particular, consider:
+
+ int f();
+ struct S { int i; };
+ const S s = { f(); }
+
+ Here, we will make "s" as TREE_READONLY (because it is declared
+ "const") -- only to reverse ourselves upon seeing that the
+ initializer is non-constant. */
+
void
cp_apply_type_quals_to_decl (int type_quals, tree decl)
{
OpenPOWER on IntegriCloud