mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 12:21:15 +08:00
re PR c++/17431 (Internal error: Segmentation fault (program cc1plus))
cp: PR c++/17431 * call.c (standard_conversion): Add FLAGS parameter. Do not allow derived to base conversion when checking constructor accessibility. (implicit_conversion): Pass FLAGS to standard_conversion. (check_constructir_callable): Disallow conversion functions. testsuite: PR c++/17431 * g++.dg/overload/arg1.C: New. * g++.dg/overload/arg2.C: New. * g++.dg/overload/arg3.C: New. * g++.dg/overload/arg4.C: New. From-SVN: r91559
This commit is contained in:
parent
eab97e449b
commit
386489e361
@ -1,3 +1,12 @@
|
||||
2004-12-01 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/17431
|
||||
* call.c (standard_conversion): Add FLAGS parameter. Do not allow
|
||||
derived to base conversion when checking constructor
|
||||
accessibility.
|
||||
(implicit_conversion): Pass FLAGS to standard_conversion.
|
||||
(check_constructir_callable): Disallow conversion functions.
|
||||
|
||||
2004-11-30 Kazu Hirata <kazu@cs.umass.edu>
|
||||
|
||||
* parser.c: Fix comment typos.
|
||||
|
@ -170,7 +170,7 @@ static struct z_candidate *add_conv_candidate
|
||||
static struct z_candidate *add_function_candidate
|
||||
(struct z_candidate **, tree, tree, tree, tree, tree, int);
|
||||
static conversion *implicit_conversion (tree, tree, tree, int);
|
||||
static conversion *standard_conversion (tree, tree, tree);
|
||||
static conversion *standard_conversion (tree, tree, tree, int);
|
||||
static conversion *reference_binding (tree, tree, tree, int);
|
||||
static conversion *build_conv (conversion_kind, tree, conversion *);
|
||||
static bool is_subseq (conversion *, conversion *);
|
||||
@ -583,7 +583,7 @@ strip_top_quals (tree t)
|
||||
also pass the expression EXPR to convert from. */
|
||||
|
||||
static conversion *
|
||||
standard_conversion (tree to, tree from, tree expr)
|
||||
standard_conversion (tree to, tree from, tree expr, int flags)
|
||||
{
|
||||
enum tree_code fcode, tcode;
|
||||
conversion *conv;
|
||||
@ -633,7 +633,7 @@ standard_conversion (tree to, tree from, tree expr)
|
||||
the standard conversion sequence to perform componentwise
|
||||
conversion. */
|
||||
conversion *part_conv = standard_conversion
|
||||
(TREE_TYPE (to), TREE_TYPE (from), NULL_TREE);
|
||||
(TREE_TYPE (to), TREE_TYPE (from), NULL_TREE, flags);
|
||||
|
||||
if (part_conv)
|
||||
{
|
||||
@ -815,7 +815,8 @@ standard_conversion (tree to, tree from, tree expr)
|
||||
else if (fcode == VECTOR_TYPE && tcode == VECTOR_TYPE
|
||||
&& vector_types_convertible_p (from, to))
|
||||
return build_conv (ck_std, to, conv);
|
||||
else if (IS_AGGR_TYPE (to) && IS_AGGR_TYPE (from)
|
||||
else if (!(flags & LOOKUP_CONSTRUCTOR_CALLABLE)
|
||||
&& IS_AGGR_TYPE (to) && IS_AGGR_TYPE (from)
|
||||
&& is_properly_derived_from (from, to))
|
||||
{
|
||||
if (conv->kind == ck_rvalue)
|
||||
@ -1227,7 +1228,7 @@ implicit_conversion (tree to, tree from, tree expr, int flags)
|
||||
if (TREE_CODE (to) == REFERENCE_TYPE)
|
||||
conv = reference_binding (to, from, expr, flags);
|
||||
else
|
||||
conv = standard_conversion (to, from, expr);
|
||||
conv = standard_conversion (to, from, expr, flags);
|
||||
|
||||
if (conv)
|
||||
return conv;
|
||||
@ -4081,6 +4082,7 @@ check_constructor_callable (tree type, tree expr)
|
||||
build_tree_list (NULL_TREE, expr),
|
||||
type,
|
||||
LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING
|
||||
| LOOKUP_NO_CONVERSION
|
||||
| LOOKUP_CONSTRUCTOR_CALLABLE);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
2004-12-01 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/17431
|
||||
* g++.dg/overload/arg1.C: New.
|
||||
* g++.dg/overload/arg2.C: New.
|
||||
* g++.dg/overload/arg3.C: New.
|
||||
* g++.dg/overload/arg4.C: New.
|
||||
|
||||
2004-12-01 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* gcc.dg/c99-flex-array-4.c: Remove.
|
||||
|
23
gcc/testsuite/g++.dg/overload/arg1.C
Normal file
23
gcc/testsuite/g++.dg/overload/arg1.C
Normal file
@ -0,0 +1,23 @@
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 30 Nov 2004 <nathan@codesourcery.com>
|
||||
|
||||
// PR 17431. copy ctor from user conv
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
struct A {};
|
||||
|
||||
struct B : A
|
||||
{
|
||||
B(int); // { dg-error "" "" }
|
||||
B(B &); // { dg-error "" "" }
|
||||
B(A); // { dg-error "" "" }
|
||||
};
|
||||
|
||||
void foo(B);
|
||||
|
||||
void bar()
|
||||
{
|
||||
foo(0); // { dg-error "no matching function|initializing" "" }
|
||||
}
|
22
gcc/testsuite/g++.dg/overload/arg2.C
Normal file
22
gcc/testsuite/g++.dg/overload/arg2.C
Normal file
@ -0,0 +1,22 @@
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 30 Nov 2004 <nathan@codesourcery.com>
|
||||
|
||||
// PR 17431. copy ctor from user conv
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
struct A {};
|
||||
|
||||
struct B : A
|
||||
{
|
||||
B(int);
|
||||
B(A);
|
||||
};
|
||||
|
||||
void foo(B);
|
||||
|
||||
void bar()
|
||||
{
|
||||
foo(0);
|
||||
}
|
22
gcc/testsuite/g++.dg/overload/arg3.C
Normal file
22
gcc/testsuite/g++.dg/overload/arg3.C
Normal file
@ -0,0 +1,22 @@
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 30 Nov 2004 <nathan@codesourcery.com>
|
||||
|
||||
// PR 17431. copy ctor from user conv
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
struct A {};
|
||||
|
||||
struct B : A
|
||||
{
|
||||
B(int); // { dg-error "" "" }
|
||||
B(B&); // { dg-error "" "" }
|
||||
};
|
||||
|
||||
void foo(B);
|
||||
|
||||
void bar()
|
||||
{
|
||||
foo(0); // { dg-error "no matching function|initializing" "" }
|
||||
}
|
30
gcc/testsuite/g++.dg/overload/arg4.C
Normal file
30
gcc/testsuite/g++.dg/overload/arg4.C
Normal file
@ -0,0 +1,30 @@
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 30 Nov 2004 <nathan@codesourcery.com>
|
||||
|
||||
// PR 17431. copy ctor from user conv
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
struct A {};
|
||||
|
||||
struct B : A
|
||||
{
|
||||
B(int); // { dg-error "" "" }
|
||||
B(B&); // { dg-error "" "" }
|
||||
B(A); // { dg-error "" "" }
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
operator B () const;
|
||||
};
|
||||
|
||||
|
||||
void foo(B);
|
||||
|
||||
void bar()
|
||||
{
|
||||
C c;
|
||||
foo(c); // { dg-error "no matching function|initializing" "" }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user