From 6d876e0b31aab2bf03e93b1d4705330f20f2c656 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 20 Jul 2012 02:29:13 -0400 Subject: re PR c++/54026 (template const struct with mutable members erroneously emitted to .rodata) PR c++/54026 * typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P. From-SVN: r189701 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 649b656..647b719 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-07-19 Jason Merrill + PR c++/54026 + * typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P. + PR c++/54021 * call.c (build_cxx_call): Set optimize when folding __builtin_constant_p in a constexpr function. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 508e8fb..d7a719f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -8453,9 +8453,9 @@ cp_apply_type_quals_to_decl (int type_quals, tree decl) constructor can produce constant init, so rely on cp_finish_decl to clear TREE_READONLY if the variable has non-constant init. */ - /* If the type has a mutable component, that component might be - modified. */ - if (TYPE_HAS_MUTABLE_P (type)) + /* If the type has (or might have) a mutable component, that component + might be modified. */ + if (TYPE_HAS_MUTABLE_P (type) || !COMPLETE_TYPE_P (type)) type_quals &= ~TYPE_QUAL_CONST; c_apply_type_quals_to_decl (type_quals, decl); -- cgit v1.1