aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/class.c3
-rw-r--r--gcc/cp/decl.c35
-rw-r--r--gcc/cp/decl2.c2
-rw-r--r--gcc/cp/method.c1
-rw-r--r--gcc/cp/pt.c1
6 files changed, 35 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 937d5e8..803644d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,16 @@
+2006-05-02 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/27309
+ * class.c (add_method): Call grok_special_member_properties.
+ * decl.c (grokdeclarator): Don't call it here.
+ (copy_fn_p): A TEMPLATE_DECL is never a copy constructor or
+ assignment operator. Set TYPE_HAS_CONSTURCTOR if DECL is a
+ constructor.
+ (start_method): Don't call grok_special_member_properties.
+ * method.c (implicitly_declare_fn): Likewise.
+ * pt.c (instantiate_class_template): Likewise.
+ * decl2.c (grokfield): Likewise.
+
2006-05-02 Jakub Jelinek <jakub@redhat.com>
PR middle-end/27337
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a7536bb..f592fe6 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -924,6 +924,9 @@ add_method (tree type, tree method, tree using_decl)
CLASSTYPE_METHOD_VEC (type) = method_vec;
}
+ /* Maintain TYPE_HAS_CONSTRUCTOR, etc. */
+ grok_special_member_properties (method);
+
/* Constructors and destructors go in special slots. */
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (method))
slot = CLASSTYPE_CONSTRUCTOR_SLOT;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e59bd68..40c2120 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7541,12 +7541,9 @@ grokdeclarator (const cp_declarator *declarator,
pedwarn ("constructors cannot be declared virtual");
virtualp = 0;
}
- if (decl_context == FIELD)
- {
- TYPE_HAS_CONSTRUCTOR (ctype) = 1;
- if (sfk != sfk_constructor)
- return NULL_TREE;
- }
+ if (decl_context == FIELD
+ && sfk != sfk_constructor)
+ return NULL_TREE;
}
if (decl_context == FIELD)
staticp = 0;
@@ -8816,8 +8813,9 @@ copy_fn_p (tree d)
gcc_assert (DECL_FUNCTION_MEMBER_P (d));
- if (DECL_TEMPLATE_INFO (d)
- && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (d)))
+ if (TREE_CODE (d) == TEMPLATE_DECL
+ || (DECL_TEMPLATE_INFO (d)
+ && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (d))))
/* Instantiations of template member functions are never copy
functions. Note that member functions of templated classes are
represented as template functions internally, and we must
@@ -8859,12 +8857,18 @@ copy_fn_p (tree d)
void grok_special_member_properties (tree decl)
{
+ tree class_type;
+
if (!DECL_NONSTATIC_MEMBER_FUNCTION_P (decl))
- ; /* Not special. */
- else if (DECL_CONSTRUCTOR_P (decl))
+ return;
+
+ class_type = DECL_CONTEXT (decl);
+ if (DECL_CONSTRUCTOR_P (decl))
{
int ctor = copy_fn_p (decl);
+ TYPE_HAS_CONSTRUCTOR (class_type) = 1;
+
if (ctor > 0)
{
/* [class.copy]
@@ -8874,12 +8878,12 @@ void grok_special_member_properties (tree decl)
X&, volatile X& or const volatile X&, and either there
are no other parameters or else all other parameters have
default arguments. */
- TYPE_HAS_INIT_REF (DECL_CONTEXT (decl)) = 1;
+ TYPE_HAS_INIT_REF (class_type) = 1;
if (ctor > 1)
- TYPE_HAS_CONST_INIT_REF (DECL_CONTEXT (decl)) = 1;
+ TYPE_HAS_CONST_INIT_REF (class_type) = 1;
}
else if (sufficient_parms_p (FUNCTION_FIRST_USER_PARMTYPE (decl)))
- TYPE_HAS_DEFAULT_CONSTRUCTOR (DECL_CONTEXT (decl)) = 1;
+ TYPE_HAS_DEFAULT_CONSTRUCTOR (class_type) = 1;
}
else if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR)
{
@@ -8893,9 +8897,9 @@ void grok_special_member_properties (tree decl)
if (assop)
{
- TYPE_HAS_ASSIGN_REF (DECL_CONTEXT (decl)) = 1;
+ TYPE_HAS_ASSIGN_REF (class_type) = 1;
if (assop != 1)
- TYPE_HAS_CONST_ASSIGN_REF (DECL_CONTEXT (decl)) = 1;
+ TYPE_HAS_CONST_ASSIGN_REF (class_type) = 1;
}
}
}
@@ -11203,7 +11207,6 @@ start_method (cp_decl_specifier_seq *declspecs,
fndecl = copy_node (fndecl);
TREE_CHAIN (fndecl) = NULL_TREE;
}
- grok_special_member_properties (fndecl);
}
finish_decl (fndecl, NULL_TREE, NULL_TREE);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index df85e4c..ac85b44 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -923,8 +923,6 @@ grokfield (const cp_declarator *declarator,
case FUNCTION_DECL:
if (asmspec)
set_user_assembler_name (value, asmspec);
- if (!DECL_FRIEND_P (value))
- grok_special_member_properties (value);
cp_finish_decl (value, init, /*init_const_expr_p=*/false,
asmspec_tree, flags);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 68ec8ab..ddf79bf 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1083,7 +1083,6 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
DECL_ARGUMENTS (fn) = this_parm;
grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
- grok_special_member_properties (fn);
set_linkage_according_to_type (type, fn);
rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
DECL_IN_AGGR_P (fn) = 1;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 43efc63..7b814ae 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5702,7 +5702,6 @@ instantiate_class_template (tree type)
if (TREE_CODE (t) == TEMPLATE_DECL)
--processing_template_decl;
set_current_access_from_decl (r);
- grok_special_member_properties (r);
finish_member_declaration (r);
}
else