This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to convert_to_void for c++/26577
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches >> GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 29 Aug 2006 00:49:30 -0400
- Subject: C++ PATCH to convert_to_void for c++/26577
The simplified testcase in 26577 has an INDIRECT_REF of volatile,
TREE_ADDRESSABLE type. The backend tries to do a load because it's
volatile, and aborts because it's not allowed to do a bitwise copy of a
TREE_ADDRESSABLE type. The fix is to disable the automatic load of such
types; the only way to load them would be to add a copy constructor
call, and that would violate the language specification.
Tested x86_64-pc-linux-gnu, applied to trunk.
2006-08-28 Jason Merrill <jason@redhat.com>
PR c++/26577
* cvt.c (convert_to_void): Don't automatically load from volatiles
of TREE_ADDRESSABLE type.
Index: cvt.c
===================================================================
*** cvt.c (revision 116352)
--- cvt.c (working copy)
*************** convert_to_void (tree expr, const char *
*** 864,877 ****
int is_volatile = TYPE_VOLATILE (type);
int is_complete = COMPLETE_TYPE_P (complete_type (type));
if (is_volatile && !is_complete)
warning (0, "object of incomplete type %qT will not be accessed in %s",
type, implicit ? implicit : "void context");
! else if (is_reference && is_volatile)
warning (0, "object of type %qT will not be accessed in %s",
TREE_TYPE (TREE_OPERAND (expr, 0)),
implicit ? implicit : "void context");
! if (is_reference || !is_volatile || !is_complete)
expr = TREE_OPERAND (expr, 0);
break;
--- 864,880 ----
int is_volatile = TYPE_VOLATILE (type);
int is_complete = COMPLETE_TYPE_P (complete_type (type));
+ /* Can't load the value if we don't know the type. */
if (is_volatile && !is_complete)
warning (0, "object of incomplete type %qT will not be accessed in %s",
type, implicit ? implicit : "void context");
! /* Don't load the value if this is an implicit dereference, or if
! the type needs to be handled by ctors/dtors. */
! else if (is_volatile && (is_reference || TREE_ADDRESSABLE (type)))
warning (0, "object of type %qT will not be accessed in %s",
TREE_TYPE (TREE_OPERAND (expr, 0)),
implicit ? implicit : "void context");
! if (is_reference || !is_volatile || !is_complete || TREE_ADDRESSABLE (type))
expr = TREE_OPERAND (expr, 0);
break;
Index: /home/jason/ged/warn/volatile1.C
===================================================================
*** /home/jason/ged/warn/volatile1.C (revision 0)
--- /home/jason/ged/warn/volatile1.C (revision 0)
***************
*** 0 ****
--- 1,12 ----
+ // PR c++/26577
+
+ struct A
+ {
+ A(const A&);
+ A& operator=(const A&);
+ void baz() volatile;
+ };
+ void A::baz() volatile
+ {
+ *this; // { dg-warning "will not be accessed" }
+ }