re PR c++/36870 (__has_nothrow_constructor violates the ODR)

/cp
2008-07-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/36870
	* semantics.c (classtype_has_nothrow_assign_or_copy_p): Use
	TYPE_NOTHROW_P, not TREE_NOTHROW.
	(trait_expr_value): Likewise.

/testsuite
2008-07-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/36870
	* g++.dg/ext/has_nothrow_assign_odr.C: New.
	* g++.dg/ext/has_nothrow_copy_odr.C: Likewise.
	* g++.dg/ext/has_nothrow_constructor_odr.C: Likewise.
	* g++.dg/ext/has_nothrow_assign.C: Adjust.
	* g++.dg/ext/has_nothrow_copy.C: Likewise.
	* g++.dg/ext/has_nothrow_constructor.C: Likewise.

From-SVN: r138024
This commit is contained in:
Paolo Carlini 2008-07-21 09:08:41 +00:00 committed by Paolo Carlini
parent c499b30003
commit e24313f349
9 changed files with 75 additions and 23 deletions

View File

@ -1,3 +1,10 @@
2008-07-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/36870
* semantics.c (classtype_has_nothrow_assign_or_copy_p): Use
TYPE_NOTHROW_P, not TREE_NOTHROW.
(trait_expr_value): Likewise.
2008-07-18 Dodji Seketeli <dseketel@redhat.com>
PR c++/36407

View File

@ -4677,7 +4677,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
return false;
for (; fns; fns = OVL_NEXT (fns))
if (!TREE_NOTHROW (OVL_CURRENT (fns)))
if (!TYPE_NOTHROW_P (TREE_TYPE (OVL_CURRENT (fns))))
return false;
return true;
@ -4712,7 +4712,8 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
type1 = strip_array_types (type1);
return (trait_expr_value (CPTK_HAS_TRIVIAL_CONSTRUCTOR, type1, type2)
|| (CLASS_TYPE_P (type1)
&& (t = locate_ctor (type1, NULL)) && TREE_NOTHROW (t)));
&& (t = locate_ctor (type1, NULL))
&& TYPE_NOTHROW_P (TREE_TYPE (t))));
case CPTK_HAS_TRIVIAL_CONSTRUCTOR:
type1 = strip_array_types (type1);

View File

@ -1,3 +1,13 @@
2008-07-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/36870
* g++.dg/ext/has_nothrow_assign_odr.C: New.
* g++.dg/ext/has_nothrow_copy_odr.C: Likewise.
* g++.dg/ext/has_nothrow_constructor_odr.C: Likewise.
* g++.dg/ext/has_nothrow_assign.C: Adjust.
* g++.dg/ext/has_nothrow_copy.C: Likewise.
* g++.dg/ext/has_nothrow_constructor.C: Likewise.
2008-07-17 Andreas Krebbel <krebbel1@de.ibm.com>
PR target/36822

View File

@ -136,19 +136,13 @@ int main()
assert (PTEST (C));
assert (NTEST (C[]));
assert (PTEST (D));
#ifndef __PIC__
assert (PTEST (E));
#endif
assert (NTEST (E));
assert (NTEST (E1));
assert (PTEST (F));
assert (PTEST (G));
#ifndef __PIC__
assert (PTEST (H));
#endif
assert (NTEST (H));
assert (NTEST (H1));
#ifndef __PIC__
assert (PTEST (I));
#endif
assert (NTEST (I));
assert (NTEST (I1));
assert (PTEST (J));
assert (NTEST (const K));

View File

@ -0,0 +1,16 @@
// PR c++/36870
// { dg-do "run" }
#include <cassert>
struct S { const S& operator= (const S&); };
bool f ();
int main ()
{
assert (__has_nothrow_assign (S) == f ());
}
const S& S::operator= (const S&) { }
bool f () { return __has_nothrow_assign (S); }

View File

@ -97,9 +97,7 @@ int main()
assert (PTEST (C));
assert (PTEST (C[]));
assert (PTEST (D));
#ifndef __PIC__
assert (PTEST (E));
#endif
assert (NTEST (E));
assert (NTEST (E1));
assert (NTEST (F));
assert (NTEST (G));

View File

@ -0,0 +1,16 @@
// PR c++/36870
// { dg-do "run" }
#include <cassert>
struct S { S (); };
bool f ();
int main ()
{
assert (__has_nothrow_constructor (S) == f ());
}
S::S () { }
bool f () { return __has_nothrow_constructor (S); }

View File

@ -126,19 +126,13 @@ int main()
assert (PTEST (C));
assert (NTEST (C[]));
assert (PTEST (D));
#ifndef __PIC__
assert (PTEST (E));
#endif
assert (NTEST (E));
assert (NTEST (E1));
assert (PTEST (F));
assert (PTEST (G));
#ifndef __PIC__
assert (PTEST (H));
#endif
assert (NTEST (H));
assert (NTEST (H1));
#ifndef __PIC__
assert (PTEST (I));
#endif
assert (NTEST (I));
assert (NTEST (I1));
assert (PTEST (J));

View File

@ -0,0 +1,16 @@
// PR c++/36870
// { dg-do "run" }
#include <cassert>
struct S { S (const S&); };
bool f ();
int main ()
{
assert (__has_nothrow_copy (S) == f ());
}
S::S (const S&) { }
bool f () { return __has_nothrow_copy (S); }