re PR c++/83796 (Abstract classes allowed to be instantiated when initialised as default parameter to function or constructor)
/cp 2018-02-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/83796 * call.c (convert_like_real): If w're initializing from {} explicitly call abstract_virtuals_error_sfinae. /testsuite 2018-02-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/83796 * g++.dg/cpp0x/abstract-default1.C: New. From-SVN: r257298
This commit is contained in:
parent
3ae129323d
commit
73b7d28f67
@ -1,3 +1,9 @@
|
||||
2018-02-01 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/83796
|
||||
* call.c (convert_like_real): If w're initializing from {} explicitly
|
||||
call abstract_virtuals_error_sfinae.
|
||||
|
||||
2018-01-31 Jason Merrill <jason@redhat.com>
|
||||
Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
|
@ -6765,6 +6765,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
|
||||
&& TYPE_HAS_DEFAULT_CONSTRUCTOR (totype))
|
||||
{
|
||||
bool direct = CONSTRUCTOR_IS_DIRECT_INIT (expr);
|
||||
if (abstract_virtuals_error_sfinae (NULL_TREE, totype, complain))
|
||||
return error_mark_node;
|
||||
expr = build_value_init (totype, complain);
|
||||
expr = get_target_expr_sfinae (expr, complain);
|
||||
if (expr != error_mark_node)
|
||||
|
@ -1,3 +1,8 @@
|
||||
2018-02-01 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/83796
|
||||
* g++.dg/cpp0x/abstract-default1.C: New.
|
||||
|
||||
2018-02-01 Richard Sandiford <richard.sandiford@linaro.org>
|
||||
|
||||
PR tree-optimization/81635
|
||||
|
26
gcc/testsuite/g++.dg/cpp0x/abstract-default1.C
Normal file
26
gcc/testsuite/g++.dg/cpp0x/abstract-default1.C
Normal file
@ -0,0 +1,26 @@
|
||||
// PR c++/83796
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
struct MyAbstractClass
|
||||
{
|
||||
virtual int foo() const = 0;
|
||||
};
|
||||
|
||||
struct TestClass
|
||||
{
|
||||
TestClass(const MyAbstractClass& m = {}) // { dg-error "abstract type" }
|
||||
: value_(m.foo()) {}
|
||||
|
||||
int value_;
|
||||
};
|
||||
|
||||
int TestFunction(const MyAbstractClass& m = {}) // { dg-error "abstract type" }
|
||||
{
|
||||
return m.foo();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
TestClass testInstance; // { dg-error "abstract type" }
|
||||
TestFunction(); // { dg-error "abstract type" }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user