re PR c++/38380 (explicitly defaulted constructors vs. empty direct initialization)
PR c++/38380 * decl.c (grokdeclarator): Only set DECL_NONCONVERTING_P on explicit constructors. * pt.c (tsubst_copy_and_build) [CONSTRUCTOR]: Propagate CONSTRUCTOR_IS_DIRECT_INIT. From-SVN: r142404
This commit is contained in:
parent
6efe1abf4c
commit
27fb09b78e
@ -1,3 +1,11 @@
|
|||||||
|
2008-12-03 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/38380
|
||||||
|
* decl.c (grokdeclarator): Only set DECL_NONCONVERTING_P
|
||||||
|
on explicit constructors.
|
||||||
|
* pt.c (tsubst_copy_and_build) [CONSTRUCTOR]: Propagate
|
||||||
|
CONSTRUCTOR_IS_DIRECT_INIT.
|
||||||
|
|
||||||
2008-12-02 Jason Merrill <jason@redhat.com>
|
2008-12-02 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/35782, c++/37860
|
PR c++/35782, c++/37860
|
||||||
|
@ -9099,15 +9099,6 @@ grokdeclarator (const cp_declarator *declarator,
|
|||||||
is called a converting constructor. */
|
is called a converting constructor. */
|
||||||
if (explicitp == 2)
|
if (explicitp == 2)
|
||||||
DECL_NONCONVERTING_P (decl) = 1;
|
DECL_NONCONVERTING_P (decl) = 1;
|
||||||
else if (DECL_CONSTRUCTOR_P (decl))
|
|
||||||
{
|
|
||||||
/* A constructor with no parms is not a conversion.
|
|
||||||
Ignore any compiler-added parms. */
|
|
||||||
tree arg_types = FUNCTION_FIRST_USER_PARMTYPE (decl);
|
|
||||||
|
|
||||||
if (arg_types == void_list_node)
|
|
||||||
DECL_NONCONVERTING_P (decl) = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (TREE_CODE (type) == METHOD_TYPE)
|
else if (TREE_CODE (type) == METHOD_TYPE)
|
||||||
{
|
{
|
||||||
|
@ -11612,6 +11612,7 @@ tsubst_copy_and_build (tree t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = build_constructor (init_list_type_node, n);
|
r = build_constructor (init_list_type_node, n);
|
||||||
|
CONSTRUCTOR_IS_DIRECT_INIT (r) = CONSTRUCTOR_IS_DIRECT_INIT (t);
|
||||||
|
|
||||||
if (TREE_HAS_CONSTRUCTOR (t))
|
if (TREE_HAS_CONSTRUCTOR (t))
|
||||||
return finish_compound_literal (type, r);
|
return finish_compound_literal (type, r);
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2008-12-03 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/38380
|
||||||
|
* g++.dg/cpp0x/initlist10.C: New test.
|
||||||
|
* g++.old-deja/g++.eh/ctor1.C: Default ctor is a candidate too.
|
||||||
|
* g++.dg/tc1/dr152.C: Likewise.
|
||||||
|
|
||||||
2008-12-03 Jakub Jelinek <jakub@redhat.com>
|
2008-12-03 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR middle-end/38360
|
PR middle-end/38360
|
||||||
|
53
gcc/testsuite/g++.dg/cpp0x/initlist10.C
Normal file
53
gcc/testsuite/g++.dg/cpp0x/initlist10.C
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// PR c++/38380
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
struct atomic_bool
|
||||||
|
{
|
||||||
|
bool _M_i;
|
||||||
|
|
||||||
|
atomic_bool() = default;
|
||||||
|
~atomic_bool() = default;
|
||||||
|
atomic_bool(const atomic_bool&) = delete;
|
||||||
|
atomic_bool& operator=(const atomic_bool&) = delete;
|
||||||
|
|
||||||
|
explicit atomic_bool(bool __i) { _M_i = __i; }
|
||||||
|
|
||||||
|
operator bool() const volatile
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace __gnu_test
|
||||||
|
{
|
||||||
|
struct direct_list_initializable
|
||||||
|
{
|
||||||
|
template<typename _Ttype, typename _Tvalue>
|
||||||
|
void
|
||||||
|
operator()()
|
||||||
|
{
|
||||||
|
struct _Concept
|
||||||
|
{
|
||||||
|
void __constraint()
|
||||||
|
{
|
||||||
|
_Ttype __v1 = { }; // default ctor
|
||||||
|
_Ttype __v2 { __a }; // single-argument ctor
|
||||||
|
}
|
||||||
|
|
||||||
|
_Tvalue __a;
|
||||||
|
};
|
||||||
|
|
||||||
|
void (_Concept::*__x)() __attribute__((unused))
|
||||||
|
= &_Concept::__constraint;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__gnu_test::direct_list_initializable test;
|
||||||
|
|
||||||
|
test.operator()<std::atomic_bool, bool>();
|
||||||
|
return 0;
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace N1 {
|
namespace N1 {
|
||||||
struct X {
|
struct X {
|
||||||
X();
|
X(); // { dg-message "candidate" }
|
||||||
explicit X(const X&);
|
explicit X(const X&);
|
||||||
};
|
};
|
||||||
void f(X);
|
void f(X);
|
||||||
@ -19,7 +19,7 @@ namespace N1 {
|
|||||||
namespace N2 {
|
namespace N2 {
|
||||||
template <class T>
|
template <class T>
|
||||||
struct X {
|
struct X {
|
||||||
X();
|
X(); // { dg-message "candidate" }
|
||||||
explicit X(const X&);
|
explicit X(const X&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// { dg-do assemble }
|
// { dg-do assemble }
|
||||||
struct A
|
struct A
|
||||||
{
|
{
|
||||||
A();
|
A(); // { dg-message "" } candidate
|
||||||
A(A&); // { dg-message "candidates" } referenced below
|
A(A&); // { dg-message "candidates" } referenced below
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user