summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cp/cp-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/cp/cp-lang.c')
-rw-r--r--contrib/gcc/cp/cp-lang.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/contrib/gcc/cp/cp-lang.c b/contrib/gcc/cp/cp-lang.c
index c40330b..7b1d860 100644
--- a/contrib/gcc/cp/cp-lang.c
+++ b/contrib/gcc/cp/cp-lang.c
@@ -1,5 +1,5 @@
/* Language-dependent hooks for C++.
- Copyright 2001 Free Software Foundation, Inc.
+ Copyright 2001, 2002 Free Software Foundation, Inc.
Contributed by Alexandre Oliva <aoliva@redhat.com>
This file is part of GNU CC.
@@ -28,7 +28,8 @@ Boston, MA 02111-1307, USA. */
#include "langhooks.h"
#include "langhooks-def.h"
-static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree));
+static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree));
+static tree cp_expr_size PARAMS ((tree));
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU C++"
@@ -43,7 +44,7 @@ static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree));
#undef LANG_HOOKS_DECODE_OPTION
#define LANG_HOOKS_DECODE_OPTION cxx_decode_option
#undef LANG_HOOKS_POST_OPTIONS
-#define LANG_HOOKS_POST_OPTIONS cxx_post_options
+#define LANG_HOOKS_POST_OPTIONS c_common_post_options
#undef LANG_HOOKS_GET_ALIAS_SET
#define LANG_HOOKS_GET_ALIAS_SET cxx_get_alias_set
#undef LANG_HOOKS_EXPAND_CONSTANT
@@ -91,6 +92,8 @@ static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree));
#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
#undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
#define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
+#undef LANG_HOOKS_EXPR_SIZE
+#define LANG_HOOKS_EXPR_SIZE cp_expr_size
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -108,3 +111,28 @@ cxx_get_alias_set (t)
return c_common_get_alias_set (t);
}
+
+/* Langhook for expr_size: Tell the backend that the value of an expression
+ of non-POD class type does not include any tail padding; a derived class
+ might have allocated something there. */
+
+static tree
+cp_expr_size (exp)
+ tree exp;
+{
+ if (CLASS_TYPE_P (TREE_TYPE (exp)))
+ {
+ /* The backend should not be interested in the size of an expression
+ of a type with both of these set; all copies of such types must go
+ through a constructor or assignment op. */
+ if (TYPE_HAS_COMPLEX_INIT_REF (TREE_TYPE (exp))
+ && TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp)))
+ abort ();
+ /* This would be wrong for a type with virtual bases, but they are
+ caught by the abort above. */
+ return CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp));
+ }
+ else
+ /* Use the default code. */
+ return lhd_expr_size (exp);
+}
OpenPOWER on IntegriCloud