aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-11-03 17:37:51 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-11-03 12:37:51 -0500
commit8452b1d3c1b7928b09215cf63a1aeb0d9ad255ac (patch)
treed21dc62a649aa12df9af2009b659425411cba4ec /gcc
parent74641843a04eb3c3bc6fd23f2267edabade504f7 (diff)
downloadgcc-8452b1d3c1b7928b09215cf63a1aeb0d9ad255ac.zip
gcc-8452b1d3c1b7928b09215cf63a1aeb0d9ad255ac.tar.gz
gcc-8452b1d3c1b7928b09215cf63a1aeb0d9ad255ac.tar.bz2
class.c (instantiate_type): Be more helpful.
* class.c (instantiate_type): Be more helpful. * decl2.c (import_export_decl): Call import_export_class. * cp-tree.h (EMPTY_CONSTRUCTOR_P): Check !TREE_HAS_CONSTRUCTOR. * decl2.c (build_expr_from_tree): Propagate TREE_HAS_CONSTRUCTOR. * pt.c (tsubst_copy): Likewise. From-SVN: r23511
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/class.c12
-rw-r--r--gcc/cp/cp-tree.h5
-rw-r--r--gcc/cp/decl2.c6
-rw-r--r--gcc/cp/pt.c19
5 files changed, 41 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9c421f6..bccf932 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+1998-11-02 Jason Merrill <jason@yorick.cygnus.com>
+
+ * class.c (instantiate_type): Be more helpful.
+
+ * decl2.c (import_export_decl): Call import_export_class.
+
+ * cp-tree.h (EMPTY_CONSTRUCTOR_P): Check !TREE_HAS_CONSTRUCTOR.
+ * decl2.c (build_expr_from_tree): Propagate TREE_HAS_CONSTRUCTOR.
+ * pt.c (tsubst_copy): Likewise.
+
1998-11-02 Mark Mitchell <mark@markmitchell.com>
* init.c (expand_vec_init): Fix off-by-one error.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1fd492f..41ca265 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5040,8 +5040,16 @@ instantiate_type (lhstype, rhs, complain)
my_friendly_assert (TREE_CODE (function) == FUNCTION_DECL, 185);
if (! DECL_STATIC_FUNCTION_P (function))
- cp_error ("reference to `%D' can only be used in a call",
- function);
+ {
+ tree t = TREE_TYPE (TREE_OPERAND (rhs, 0));
+ if (TYPE_MAIN_VARIANT (t) == current_class_type)
+ t = constructor_name (t);
+
+ cp_error ("object-dependent reference to `%D' can only be used in a call",
+ function);
+ cp_error (" to form a pointer to member function, say `&%T::%D'",
+ t, DECL_NAME (function));
+ }
mark_used (function);
return function;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index aee859a..3f24653 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1482,8 +1482,9 @@ extern int flag_new_for_scope;
has been duly initialized in its constructor. */
#define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4(NODE))
-#define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \
- && CONSTRUCTOR_ELTS (NODE) == NULL_TREE)
+#define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \
+ && CONSTRUCTOR_ELTS (NODE) == NULL_TREE \
+ && ! TREE_HAS_CONSTRUCTOR (NODE))
#if 0
/* Indicates that a NON_LVALUE_EXPR came from a C++ reference.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 7b0ba6d..cad6078 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2785,6 +2785,7 @@ import_export_decl (decl)
else if (DECL_FUNCTION_MEMBER_P (decl))
{
tree ctype = DECL_CLASS_CONTEXT (decl);
+ import_export_class (ctype);
if (CLASSTYPE_INTERFACE_KNOWN (ctype)
&& (! DECL_ARTIFICIAL (decl) || DECL_VINDEX (decl)))
{
@@ -2803,6 +2804,10 @@ import_export_decl (decl)
else if (DECL_ARTIFICIAL (decl) && DECL_MUTABLE_P (decl))
{
tree ctype = TREE_TYPE (DECL_NAME (decl));
+
+ if (IS_AGGR_TYPE (ctype))
+ import_export_class (ctype);
+
if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype)
&& TYPE_VIRTUAL_P (ctype)
/* If the type is a cv-qualified variant of a type, then we
@@ -3852,6 +3857,7 @@ build_expr_from_tree (t)
r = build_nt (CONSTRUCTOR, NULL_TREE,
build_expr_from_tree (CONSTRUCTOR_ELTS (t)));
+ TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t);
if (TREE_TYPE (t))
return digest_init (TREE_TYPE (t), r, 0);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d4bdf82..b25929e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5917,6 +5917,7 @@ tsubst_copy (t, args, in_decl)
tree in_decl;
{
enum tree_code code;
+ tree r;
if (t == NULL_TREE || t == error_mark_node)
return t;
@@ -6000,7 +6001,7 @@ tsubst_copy (t, args, in_decl)
if (id != TREE_OPERAND (t, 0))
{
- tree r = build_nt (LOOKUP_EXPR, id);
+ r = build_nt (LOOKUP_EXPR, id);
LOOKUP_EXPR_GLOBAL (r) = LOOKUP_EXPR_GLOBAL (t);
t = r;
}
@@ -6119,7 +6120,7 @@ tsubst_copy (t, args, in_decl)
case COND_EXPR:
case MODOP_EXPR:
{
- tree r = build_nt
+ r = build_nt
(code, tsubst_copy (TREE_OPERAND (t, 0), args, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, in_decl),
tsubst_copy (TREE_OPERAND (t, 2), args, in_decl));
@@ -6142,7 +6143,7 @@ tsubst_copy (t, args, in_decl)
case NEW_EXPR:
{
- tree r = build_nt
+ r = build_nt
(code, tsubst_copy (TREE_OPERAND (t, 0), args, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, in_decl),
tsubst_copy (TREE_OPERAND (t, 2), args, in_decl));
@@ -6152,7 +6153,7 @@ tsubst_copy (t, args, in_decl)
case DELETE_EXPR:
{
- tree r = build_nt
+ r = build_nt
(code, tsubst_copy (TREE_OPERAND (t, 0), args, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, in_decl));
DELETE_EXPR_USE_GLOBAL (r) = DELETE_EXPR_USE_GLOBAL (t);
@@ -6223,9 +6224,13 @@ tsubst_copy (t, args, in_decl)
return t;
case CONSTRUCTOR:
- return build
- (CONSTRUCTOR, tsubst (TREE_TYPE (t), args, in_decl), NULL_TREE,
- tsubst_copy (CONSTRUCTOR_ELTS (t), args, in_decl));
+ {
+ r = build
+ (CONSTRUCTOR, tsubst (TREE_TYPE (t), args, in_decl), NULL_TREE,
+ tsubst_copy (CONSTRUCTOR_ELTS (t), args, in_decl));
+ TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t);
+ return r;
+ }
default:
return t;