* cp-tree.h (DECL_ANON_UNION_ELEMS): New macro.
* decl2.c (finish_anon_union): Set DECL_ANON_UNION_ELEMS.
Don't call expand_anon_union_decl here
* semantics.c (exapnd_stmt): Call it here, instead.
* typeck.c (mark_addressable): Addressed variables are implicitly
used.
From-SVN: r29645
+1999-09-23 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (DECL_ANON_UNION_ELEMS): New macro.
+ * decl2.c (finish_anon_union): Set DECL_ANON_UNION_ELEMS.
+ Don't call expand_anon_union_decl here
+ * semantics.c (exapnd_stmt): Call it here, instead.
+ * typeck.c (mark_addressable): Addressed variables are implicitly
+ used.
+
1999-09-23 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* cp-tree.h (VAR_OR_FUNCTION_DECL_CHECK): New macro.
calling the function. The TREE_VALUE is the declaration for the
virtual function itself. When CLASSTYPE_COM_INTERFACE_P does not
hold, the first entry does not have a TREE_VALUE; it is just an
- offset. */
+ offset.
+
+ DECL_ARGUMENTS
+ For a VAR_DECL this is DECL_ANON_UNION_ELEMS. */
/* Language-specific tree checkers. */
#define SET_ANON_AGGR_TYPE_P(NODE) \
(TYPE_LANG_SPECIFIC (NODE)->anon_aggr = 1)
+/* For a VAR_DECL that is an anonymous union, these are the various
+ sub-variables that make up the anonymous union. */
+#define DECL_ANON_UNION_ELEMS(NODE) DECL_ARGUMENTS ((NODE))
+
#define UNKNOWN_TYPE LANG_TYPE
/* Define fields and accessors for nodes representing declared names. */
tree anon_union_decl;
{
tree type = TREE_TYPE (anon_union_decl);
- tree elems = NULL_TREE;
tree main_decl;
int public_p = TREE_PUBLIC (anon_union_decl);
int static_p = TREE_STATIC (anon_union_decl);
return;
}
- main_decl = build_anon_union_vars (anon_union_decl, &elems,
+ main_decl = build_anon_union_vars (anon_union_decl,
+ &DECL_ANON_UNION_ELEMS (anon_union_decl),
static_p, external_p);
if (main_decl == NULL_TREE)
{
make_decl_rtl (main_decl, 0, toplevel_bindings_p ());
DECL_RTL (anon_union_decl) = DECL_RTL (main_decl);
+ expand_anon_union_decl (anon_union_decl,
+ NULL_TREE,
+ DECL_ANON_UNION_ELEMS (anon_union_decl));
}
-
- /* The following call assumes that there are never any cleanups
- for anonymous unions--a reasonable assumption. */
- expand_anon_union_decl (anon_union_decl, NULL_TREE, elems);
+ else
+ add_decl_stmt (anon_union_decl);
}
/* Finish processing a builtin type TYPE. It's name is NAME,
if (TREE_CODE (decl) == VAR_DECL
&& !TREE_STATIC (decl)
&& !DECL_EXTERNAL (decl))
- /* Let the back-end know about this variable. */
- emit_local_var (decl);
+ {
+ /* Let the back-end know about this variable. */
+ if (!ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
+ emit_local_var (decl);
+ else
+ expand_anon_union_decl (decl, NULL_TREE,
+ DECL_ANON_UNION_ELEMS (decl));
+ }
resume_momentary (i);
}
&& !DECL_ARTIFICIAL (x) && extra_warnings)
cp_warning ("address requested for `%D', which is declared `register'",
x);
- put_var_into_stack (x);
TREE_ADDRESSABLE (x) = 1;
+ TREE_USED (x) = 1;
+ if (current_function && expanding_p)
+ put_var_into_stack (x);
return 1;
case FUNCTION_DECL:
--- /dev/null
+// Build don't link:
+// Origin: Thomas Kunert <kunert@physik.tu-dresden.de>
+// Special g++ Options: -O
+
+struct C {
+ ~C();
+};
+
+struct R {
+ bool empty() const;
+ C m_;
+};
+
+struct R1 {
+ R1( const R& a );
+ ~R1 ();
+ C m_;
+};
+
+R1 get_empty();
+
+R1::R1( const R& a ) :
+ m_( a.empty() ? get_empty().m_ : C() )
+{}
+
+void qnorm( const R & r)
+{ R1 n( r ); }