Commit 6d876e0b by Jason Merrill Committed by Jason Merrill

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
parent c62c6622
2012-07-19 Jason Merrill <jason@redhat.com> 2012-07-19 Jason Merrill <jason@redhat.com>
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
PR c++/54021 PR c++/54021
* call.c (build_cxx_call): Set optimize when folding * call.c (build_cxx_call): Set optimize when folding
__builtin_constant_p in a constexpr function. __builtin_constant_p in a constexpr function.
......
...@@ -8453,9 +8453,9 @@ cp_apply_type_quals_to_decl (int type_quals, tree decl) ...@@ -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 constructor can produce constant init, so rely on cp_finish_decl to
clear TREE_READONLY if the variable has non-constant init. */ clear TREE_READONLY if the variable has non-constant init. */
/* If the type has a mutable component, that component might be /* If the type has (or might have) a mutable component, that component
modified. */ might be modified. */
if (TYPE_HAS_MUTABLE_P (type)) if (TYPE_HAS_MUTABLE_P (type) || !COMPLETE_TYPE_P (type))
type_quals &= ~TYPE_QUAL_CONST; type_quals &= ~TYPE_QUAL_CONST;
c_apply_type_quals_to_decl (type_quals, decl); c_apply_type_quals_to_decl (type_quals, decl);
......
2012-07-19 Jason Merrill <jason@redhat.com>
PR c++/54026
* g++.dg/init/mutable1.C: New.
2012-07-20 Tobias Burnus <burnus@net-b.de> 2012-07-20 Tobias Burnus <burnus@net-b.de>
PR fortran/48820 PR fortran/48820
......
// 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 };
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