OSDN Git Service

* class.c (instantiate_type): Be more helpful.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Nov 1998 17:37:51 +0000 (17:37 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Nov 1998 17:37:51 +0000 (17:37 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23511 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/pt.c

index 9c421f6..bccf932 100644 (file)
@@ -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.
index 1fd492f..41ca265 100644 (file)
@@ -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;
index aee859a..3f24653 100644 (file)
@@ -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.
index 7b0ba6d..cad6078 100644 (file)
@@ -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);
index d4bdf82..b25929e 100644 (file)
@@ -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;