+2001-12-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/335
+ * init.c (resolve_offset_ref): Copy cv qualifiers of this pointer
+ for non-reference fields.
+ * typeck.c (require_complete_type): Use resolve_offset_ref).
+
2001-12-26 Nathan Sidwell <nathan@codesourcery.com>
PR c++/196
- * cp/parse.y (bad_parm): Better diagnostic when given a SCOPE_REF.
+ * parse.y (bad_parm): Better diagnostic when given a SCOPE_REF.
2001-12-24 Nathan Sidwell <nathan@codesourcery.com>
if (expr == error_mark_node)
return error_mark_node;
- expr = build (COMPONENT_REF, TREE_TYPE (member),
- expr, member);
+ type = TREE_TYPE (member);
+ if (TREE_CODE (type) != REFERENCE_TYPE)
+ {
+ int quals = cp_type_quals (type) | cp_type_quals (TREE_TYPE (expr));
+
+ if (DECL_MUTABLE_P (member))
+ quals &= ~TYPE_QUAL_CONST;
+
+ type = cp_build_qualified_type (type, quals);
+ }
+
+ expr = build (COMPONENT_REF, type, expr, member);
return convert_from_reference (expr);
}
&& current_class_ref != 0
&& TREE_OPERAND (value, 0) == current_class_ref)
{
- tree base, member = TREE_OPERAND (value, 1);
- tree basetype = TYPE_OFFSET_BASETYPE (type);
-
- my_friendly_assert (TREE_CODE (member) == FIELD_DECL, 305);
- basetype = lookup_base (current_class_type, basetype, ba_check, NULL);
- base = build_base_path (PLUS_EXPR, current_class_ptr, basetype, 1);
-
- value = build (COMPONENT_REF, TREE_TYPE (member),
- build_indirect_ref (base, NULL), member);
+ value = resolve_offset_ref (value);
return require_complete_type (value);
}
+2001-12-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.dg/other/const1.C: New test.
+
2001-12-29 Hans-Peter Nilsson <hp@bitrange.com>
* gcc.c-torture/compile/20011229-1.c: New test.
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>
+
+// PR 335. Missed diagnostic
+
+struct Foo
+{
+ unsigned i;
+ void Modify(unsigned j) const;
+};
+
+void Foo::Modify(unsigned j) const
+{
+ Foo::i = j; // { dg-error "assignment of data-member" "" }
+}