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: r189702
This commit is contained in:
Jason Merrill 2012-07-20 02:29:33 -04:00 committed by Jason Merrill
parent 767bfa9761
commit b0e0072087
4 changed files with 33 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2012-07-19 Jason Merrill <jason@redhat.com>
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
2012-07-18 Jason Merrill <jason@redhat.com>
* method.c (process_subob_fn): Make sure no_implicit_p is non-null

View File

@ -8296,9 +8296,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);

View File

@ -1,3 +1,8 @@
2012-07-19 Jason Merrill <jason@redhat.com>
PR c++/54026
* g++.dg/init/mutable1.C: New.
2012-07-19 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt25.adb: New test.

View File

@ -0,0 +1,20 @@
// PR c++/54026
// { dg-final { scan-assembler-not "rodata" } }
void non_const(int *);
template <typename T>
struct Foo {
T x;
mutable int y;
void func() const { non_const(&y); }
};
struct Bar {
int x;
mutable int y;
void func() const { non_const(&y); }
};
const Foo<int> foo = { 1, 2 };
const Bar bar = { 3, 4 };