2009-03-04 Jason Merrill <jason@redhat.com>
+ PR c++/38908
+ * class.c (is_really_empty_class): New fn.
+ * cp-tree.h: Declare it.
+ * cp-objcp-common.c (cp_expr_size): Use it.
+
PR c++/13549
* semantics.c (perform_koenig_lookup): Handle TEMPLATE_ID_EXPR.
* parser.c (cp_parser_postfix_expression): Call it for
if (type == error_mark_node)
return 0;
- if (! MAYBE_CLASS_TYPE_P (type))
+ if (! CLASS_TYPE_P (type))
return 0;
/* In G++ 3.2, whether or not a class was empty was determined by
return false;
}
+/* Returns true if TYPE contains no actual data, just various
+ possible combinations of empty classes. */
+
+bool
+is_really_empty_class (tree type)
+{
+ if (is_empty_class (type))
+ return true;
+ if (CLASS_TYPE_P (type))
+ {
+ tree field;
+ tree binfo;
+ tree base_binfo;
+ int i;
+
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
+ if (!is_really_empty_class (BINFO_TYPE (base_binfo)))
+ return false;
+ for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+ if (TREE_CODE (field) == FIELD_DECL
+ && !DECL_ARTIFICIAL (field)
+ && !is_really_empty_class (TREE_TYPE (field)))
+ return false;
+ return true;
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ return is_really_empty_class (TREE_TYPE (type));
+ return false;
+}
+
/* Note that NAME was looked up while the current class was being
defined and that the result of that lookup was DECL. */
constructed, this is a valid transformation. */
|| CP_AGGREGATE_TYPE_P (type))
/* This would be wrong for a type with virtual bases. */
- return (is_empty_class (type)
+ return (is_really_empty_class (type)
? size_zero_node
: CLASSTYPE_SIZE_UNIT (type));
else
extern int resolves_to_fixed_type_p (tree, int *);
extern void init_class_processing (void);
extern int is_empty_class (tree);
+extern bool is_really_empty_class (tree);
extern void pushclass (tree);
extern void popclass (void);
extern void push_nested_class (tree);
+2009-03-05 Jason Merrill <jason@redhat.com>
+
+ PR c++/38908
+ * g++.dg/warn/Wuninitialized-3.C: New test.
+
2009-03-05 Jakub Jelinek <jakub@redhat.com>
PR debug/39379
--- /dev/null
+// PR C++/38908
+// { dg-options "-Wuninitialized -O" }
+
+struct empty {};
+
+struct dfs_visitor {
+ dfs_visitor() { }
+ empty m_vis;
+};
+
+void bar(const dfs_visitor&);
+void foo(void)
+{
+ dfs_visitor vis;
+ dfs_visitor vis2 = vis;
+ bar (vis2);
+}