re PR c++/27309 (ICE on invalid constructor definition)
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. PR c++/27309 * g++.dg/parser/ctor5.C: New test. From-SVN: r113473
This commit is contained in:
parent
263bb8fb86
commit
7137605e8f
8 changed files with 54 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2006-05-02 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/27309
|
||||
* g++.dg/parser/ctor5.C: New test.
|
||||
|
||||
2006-05-02 Kazu Hirata <kazu@codesourcery.com>
|
||||
|
||||
PR target/27387
|
||||
|
|
14
gcc/testsuite/g++.dg/parse/ctor5.C
Normal file
14
gcc/testsuite/g++.dg/parse/ctor5.C
Normal file
|
@ -0,0 +1,14 @@
|
|||
// PR c++/27309
|
||||
|
||||
struct A
|
||||
{
|
||||
int i;
|
||||
A() i() {} // { dg-error "expected" }
|
||||
}; // { dg-error "expected" }
|
||||
|
||||
struct B
|
||||
{
|
||||
A a;
|
||||
};
|
||||
|
||||
B b;
|
Loading…
Add table
Reference in a new issue