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
This commit is contained in:
parent
59581da697
commit
570221c201
|
@ -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>
|
Wed Apr 1 14:58:35 1998 Mark Mitchell <mmitchell@usa.net>
|
||||||
|
|
||||||
* call.c (build_over_call): Do name resolution for default
|
* call.c (build_over_call): Do name resolution for default
|
||||||
|
|
18
gcc/cp/NEWS
18
gcc/cp/NEWS
|
@ -1,9 +1,25 @@
|
||||||
*** Changes since EGCS 1.0:
|
*** 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.
|
* 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:
|
*** Changes in EGCS 1.0:
|
||||||
|
|
||||||
* A public review copy of the December 1996 Draft of the ISO/ANSI C++
|
* A public review copy of the December 1996 Draft of the ISO/ANSI C++
|
||||||
|
|
|
@ -24,11 +24,12 @@ Boston, MA 02111-1307, USA. */
|
||||||
/* High-level class interface. */
|
/* High-level class interface. */
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "tree.h"
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "tree.h"
|
||||||
#include "cp-tree.h"
|
#include "cp-tree.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "flags.h"
|
#include "flags.h"
|
||||||
|
#include "rtl.h"
|
||||||
|
|
||||||
#include "obstack.h"
|
#include "obstack.h"
|
||||||
#define obstack_chunk_alloc xmalloc
|
#define obstack_chunk_alloc xmalloc
|
||||||
|
@ -492,6 +493,7 @@ build_call (function, result_type, parms)
|
||||||
tree function, result_type, parms;
|
tree function, result_type, parms;
|
||||||
{
|
{
|
||||||
int is_constructor = 0;
|
int is_constructor = 0;
|
||||||
|
tree tmp;
|
||||||
|
|
||||||
function = build_addr_func (function);
|
function = build_addr_func (function);
|
||||||
|
|
||||||
|
@ -506,6 +508,20 @@ build_call (function, result_type, parms)
|
||||||
&& DECL_CONSTRUCTOR_P (TREE_OPERAND (function, 0)))
|
&& DECL_CONSTRUCTOR_P (TREE_OPERAND (function, 0)))
|
||||||
is_constructor = 1;
|
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);
|
function = build_nt (CALL_EXPR, function, parms, NULL_TREE);
|
||||||
TREE_HAS_CONSTRUCTOR (function) = is_constructor;
|
TREE_HAS_CONSTRUCTOR (function) = is_constructor;
|
||||||
TREE_TYPE (function) = result_type;
|
TREE_TYPE (function) = result_type;
|
||||||
|
|
|
@ -5526,3 +5526,19 @@ build_self_reference ()
|
||||||
pushdecl_class_level (value);
|
pushdecl_class_level (value);
|
||||||
return 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);
|
||||||
|
}
|
||||||
|
|
|
@ -44,15 +44,6 @@ is_friend (type, supplicant)
|
||||||
|
|
||||||
declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd');
|
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)
|
if (declp)
|
||||||
/* It's a function decl. */
|
/* It's a function decl. */
|
||||||
{
|
{
|
||||||
|
@ -121,8 +112,10 @@ is_friend (type, supplicant)
|
||||||
|
|
||||||
if (declp && DECL_FUNCTION_MEMBER_P (supplicant))
|
if (declp && DECL_FUNCTION_MEMBER_P (supplicant))
|
||||||
context = DECL_CLASS_CONTEXT (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
|
else
|
||||||
/* Nested classes don't inherit the access of their enclosing class. */
|
|
||||||
context = NULL_TREE;
|
context = NULL_TREE;
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
|
|
Loading…
Reference in New Issue