aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-04-01 17:05:25 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-04-01 12:05:25 -0500
commit570221c20101ecc72f193e2b88e39069e05c963d (patch)
treec1e54f83c5989df56ecb7ded908c39c5421e4413
parent59581da6977aeae5819b43ebdd1eed1ee7f0d514 (diff)
downloadgcc-570221c20101ecc72f193e2b88e39069e05c963d.zip
gcc-570221c20101ecc72f193e2b88e39069e05c963d.tar.gz
gcc-570221c20101ecc72f193e2b88e39069e05c963d.tar.bz2
friend.c (is_friend): Fix access control for local classes.
* friend.c (is_friend): Fix access control for local classes. * class.c (is_empty_class): New fn. * call.c (build_call): Don't pass empty class objects to a function. From-SVN: r18933
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/NEWS18
-rw-r--r--gcc/cp/call.c18
-rw-r--r--gcc/cp/class.c16
-rw-r--r--gcc/cp/friend.c13
5 files changed, 60 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7d96732..8536976 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+Wed Apr 1 15:38:36 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * friend.c (is_friend): Fix access control for local classes.
+
+ * class.c (is_empty_class): New fn.
+ * call.c (build_call): Don't pass empty class objects to a function.
+
Wed Apr 1 14:58:35 1998 Mark Mitchell <mmitchell@usa.net>
* call.c (build_over_call): Do name resolution for default
diff --git a/gcc/cp/NEWS b/gcc/cp/NEWS
index 82a7578..ebfe314 100644
--- a/gcc/cp/NEWS
+++ b/gcc/cp/NEWS
@@ -1,9 +1,25 @@
*** Changes since EGCS 1.0:
-* Template template parameters are now supported.
+* Massive template improvements:
+ + member template classes are supported.
+ + template friends are supported.
+ + template template parameters are supported.
+ + local classes in templates are supported.
+ + lots of bugs fixed.
* operator new now throws bad_alloc where appropriate.
+* Exception handling is now thread safe, and supports nested
+ exceptions and placement delete.
+
+* protected virtual inheritance is now supported.
+
+* Loops are optimized better; we now move the test to the end in most
+ cases, like the C frontend does.
+
+* For class D derived from B which has a member 'int i', &D::i is now of
+ type 'int B::*' instead of 'int D::*'.
+
*** Changes in EGCS 1.0:
* A public review copy of the December 1996 Draft of the ISO/ANSI C++
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ab3e05e..dc5957d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -24,11 +24,12 @@ Boston, MA 02111-1307, USA. */
/* High-level class interface. */
#include "config.h"
-#include "tree.h"
#include "system.h"
+#include "tree.h"
#include "cp-tree.h"
#include "output.h"
#include "flags.h"
+#include "rtl.h"
#include "obstack.h"
#define obstack_chunk_alloc xmalloc
@@ -492,6 +493,7 @@ build_call (function, result_type, parms)
tree function, result_type, parms;
{
int is_constructor = 0;
+ tree tmp;
function = build_addr_func (function);
@@ -506,6 +508,20 @@ build_call (function, result_type, parms)
&& DECL_CONSTRUCTOR_P (TREE_OPERAND (function, 0)))
is_constructor = 1;
+ /* Don't actually pass empty class objects to a function. This is useful
+ for tags in STL, which are used to control overload resolution.
+ We don't need to handle other cases of copying empty classes. */
+ for (tmp = parms; tmp; tmp = TREE_CHAIN (tmp))
+ if (is_empty_class (TREE_TYPE (TREE_VALUE (tmp)))
+ && ! TREE_ADDRESSABLE (TREE_TYPE (TREE_VALUE (tmp))))
+ {
+ tree t = make_node (RTL_EXPR);
+ TREE_TYPE (t) = TREE_TYPE (TREE_VALUE (tmp));
+ RTL_EXPR_RTL (t) = const0_rtx;
+ RTL_EXPR_SEQUENCE (t) = NULL_RTX;
+ TREE_VALUE (tmp) = t;
+ }
+
function = build_nt (CALL_EXPR, function, parms, NULL_TREE);
TREE_HAS_CONSTRUCTOR (function) = is_constructor;
TREE_TYPE (function) = result_type;
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d725124..73701d2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5526,3 +5526,19 @@ build_self_reference ()
pushdecl_class_level (value);
return value;
}
+
+/* Returns 1 if TYPE contains only padding bytes. */
+
+int
+is_empty_class (type)
+ tree type;
+{
+ tree t;
+
+ if (! IS_AGGR_TYPE (type) || TYPE_BINFO_BASETYPES (type))
+ return 0;
+ t = TYPE_FIELDS (type);
+ while (t && TREE_CODE (t) != FIELD_DECL)
+ t = TREE_CHAIN (t);
+ return (t == NULL_TREE);
+}
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index b1f1285..9a86ebc 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -44,15 +44,6 @@ is_friend (type, supplicant)
declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd');
- /* Local classes have the same access as the enclosing function. */
- context = declp ? supplicant : TYPE_MAIN_DECL (supplicant);
- context = hack_decl_function_context (context);
- if (context)
- {
- supplicant = context;
- declp = 1;
- }
-
if (declp)
/* It's a function decl. */
{
@@ -121,8 +112,10 @@ is_friend (type, supplicant)
if (declp && DECL_FUNCTION_MEMBER_P (supplicant))
context = DECL_CLASS_CONTEXT (supplicant);
+ else if (! declp)
+ /* Local classes have the same access as the enclosing function. */
+ context = hack_decl_function_context (TYPE_MAIN_DECL (supplicant));
else
- /* Nested classes don't inherit the access of their enclosing class. */
context = NULL_TREE;
if (context)