summaryrefslogtreecommitdiffstats
path: root/gcc/cp
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1998-12-03 16:58:03 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1998-12-03 16:58:03 +0000
commit1fc849290e875a9511dbdb80140fbf4c5524ad46 (patch)
treeb46735bab28a343106b9d77c6ed5d1bb21f63107 /gcc/cp
parent5d9e72b0cef9fb8b3c79b11fd94c323d70d6a193 (diff)
downloadppe42-gcc-1fc849290e875a9511dbdb80140fbf4c5524ad46.tar.gz
ppe42-gcc-1fc849290e875a9511dbdb80140fbf4c5524ad46.zip
* class.c (handle_using_decl): Fix comment. Don't lookup
constructors in base classes. (validate_lhs): Fix typo in comment. * search.c (lookup_field_1): Don't return a USING_DECL. * cp-tree.h (DECL_ACCESS): Improve documentation. * decl.c (expand_static_init): Don't set the initialization-done flag until the initialization is done. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24076 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/class.c12
-rw-r--r--gcc/cp/cp-tree.h8
-rw-r--r--gcc/cp/decl.c39
-rw-r--r--gcc/cp/search.c9
5 files changed, 69 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 336e694d876..41e9f2ff959 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+1998-12-03 Mark Mitchell <mark@markmitchell.com>
+
+ * class.c (handle_using_decl): Fix comment. Don't lookup
+ constructors in base classes.
+ (validate_lhs): Fix typo in comment.
+ * search.c (lookup_field_1): Don't return a USING_DECL.
+
+ * cp-tree.h (DECL_ACCESS): Improve documentation.
+
+ * decl.c (expand_static_init): Don't set the initialization-done
+ flag until the initialization is done.
+
1998-12-02 Mark Mitchell <mark@markmitchell.com>
* decl2.c (validate_nonmember_using_decl): Complain about using
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a2e824478e8..8cd1c82ba8d 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1457,8 +1457,7 @@ alter_access (t, binfo, fdecl, access)
}
/* Process the USING_DECL, which is a member of T. The METHOD_VEC, if
- non-NULL, is the methods of T. The FIELDS are the fields of T.
- Returns 1 if the USING_DECL was valid, 0 otherwise. */
+ non-NULL, is the methods of T. The FIELDS are the fields of T. */
void
handle_using_decl (using_decl, t, method_vec, fields)
@@ -1485,8 +1484,11 @@ handle_using_decl (using_decl, t, method_vec, fields)
if (name == constructor_name (ctype)
|| name == constructor_name_full (ctype))
- cp_error_at ("using-declaration for constructor", using_decl);
-
+ {
+ cp_error_at ("using-declaration for constructor", using_decl);
+ return;
+ }
+
fdecl = lookup_member (binfo, name, 0, 0);
if (!fdecl)
@@ -4994,7 +4996,7 @@ validate_lhs (lhstype, complain)
/* This function will instantiate the type of the expression given in
RHS to match the type of LHSTYPE. If errors exist, then return
- error_mark_node. If only complain is COMPLAIN is set. If we are
+ error_mark_node. We only complain is COMPLAIN is set. If we are
not complaining, never modify rhs, as overload resolution wants to
try many possible instantiations, in hopes that at least one will
work.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 09928446733..8f2dc856c98 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1687,8 +1687,12 @@ extern int flag_new_for_scope;
NULL_TREE. */
#define DECL_FRIENDLIST(NODE) (DECL_INITIAL (NODE))
-/* The DECL_ACCESS is used to record under which context
- special access rules apply. */
+/* The DECL_ACCESS, if non-NULL, is a TREE_LIST. The TREE_PURPOSE of
+ each node is a type; the TREE_VALUE is the access granted for this
+ DECL in that type. The DECL_ACCESS is set by access declarations.
+ For example, if a member that would normally be public in a
+ derived class is made protected, then the derived class and the
+ protected_access_node will appear in the DECL_ACCESS for the node. */
#define DECL_ACCESS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.access)
/* C++: all of these are overloaded!
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index cbb284e9f2b..4a4f13822ac 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7869,14 +7869,39 @@ expand_static_init (decl, init)
/* Remember this information until end of file. */
push_obstacks (&permanent_obstack, &permanent_obstack);
- /* Emit code to perform this initialization but once. */
+ /* Emit code to perform this initialization but once. This code
+ looks like:
+
+ static int temp = 0;
+ if (!temp) {
+ // Do initialization.
+ temp = 1;
+ // Register variable for destruction at end of program.
+ }
+
+ Note that the `temp' variable is only set to 1 *after* the
+ initialization is complete. This ensures that an exception,
+ thrown during the construction, will cause the variable to
+ reinitialized when we pass through this code again, as per:
+
+ [stmt.dcl]
+
+ If the initialization exits by throwing an exception, the
+ initialization is not complete, so it will be tried again
+ the next time control enters the declaration.
+
+ In theory, this process should be thread-safe, too; multiple
+ threads should not be able to initialize the variable more
+ than once. We don't yet attempt to ensure thread-safety. */
temp = get_temp_name (integer_type_node, 1);
rest_of_decl_compilation (temp, NULL_PTR, 0, 0);
+
+ /* Begin the conditional initialization. */
expand_start_cond (build_binary_op (EQ_EXPR, temp,
integer_zero_node, 1), 0);
expand_start_target_temps ();
- expand_assignment (temp, integer_one_node, 0, 0);
+ /* Do the initialization itself. */
if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))
|| (init && TREE_CODE (init) == TREE_LIST))
{
@@ -7886,9 +7911,17 @@ expand_static_init (decl, init)
else if (init)
expand_assignment (decl, init, 0, 0);
- /* Cleanup any temporaries needed for the initial value. */
+ /* Set TEMP to 1. */
+ expand_assignment (temp, integer_one_node, 0, 0);
+
+ /* Cleanup any temporaries needed for the initial value. If
+ destroying one of the temporaries causes an exception to be
+ thrown, then the object itself has still been fully
+ constructed. */
expand_end_target_temps ();
+ /* Use atexit to register a function for destroying this static
+ variable. */
if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
{
tree cleanup, fcall;
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 94fdbc28cee..8b1576458f9 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -523,7 +523,14 @@ lookup_field_1 (type, name)
if (temp)
return temp;
}
- if (DECL_NAME (field) == name)
+ if (TREE_CODE (field) == USING_DECL)
+ /* For now, we're just treating member using declarations as
+ old ARM-style access declarations. Thus, there's no reason
+ to return a USING_DECL, and the rest of the compiler can't
+ handle it. Once the class is defined, these are purged
+ from TYPE_FIELDS anyhow; see handle_using_decl. */
+ ;
+ else if (DECL_NAME (field) == name)
{
if ((TREE_CODE(field) == VAR_DECL || TREE_CODE(field) == CONST_DECL)
&& DECL_ASSEMBLER_NAME (field) != NULL)
OpenPOWER on IntegriCloud