re PR c++/63959 (G++ misreports volatile int as trivially copyable)
authorVille Voutilainen <ville.voutilainen@gmail.com>
Thu, 20 Nov 2014 21:51:04 +0000 (23:51 +0200)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 20 Nov 2014 21:51:04 +0000 (16:51 -0500)
PR c++/63959
* tree.c (trivially_copyable_p): Check for CP_TYPE_VOLATILE_P.

From-SVN: r217893

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
libstdc++-v3/testsuite/20_util/is_trivially_copyable/value.cc

index 3111050cb62a3e1248dbffe394217c4d15edbb2c..2c98a7103d1292f936572386577f077bc0b16890 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-20  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       PR c++/63959
+       * tree.c (trivially_copyable_p): Check for CP_TYPE_VOLATILE_P.
+
 2014-11-20  Trevor Saunders  <tsaunders@mozilla.com>
 
        * cp-objcp-common.c: Use hash_table instead of htab.
index 4502273fb572ca440af5d5324bb3cb2fbc6d143d..f8506f512bcf538ce62342129c61613a28d67ab8 100644 (file)
@@ -3206,7 +3206,7 @@ trivially_copyable_p (const_tree t)
            && !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
            && TYPE_HAS_TRIVIAL_DESTRUCTOR (t));
   else
-    return scalarish_type_p (t);
+    return !CP_TYPE_VOLATILE_P (t) && scalarish_type_p (t);
 }
 
 /* Returns 1 iff type T is a trivial type, as defined in [basic.types] and
index f558538694c69f6980a040683ac163e83549c832..c8663739e7dbe56d66fc891c08ac234757997c7f 100644 (file)
@@ -33,3 +33,6 @@ SA(__is_trivially_constructible(int,double));
 SA(!__is_trivially_constructible(int,B));
 
 SA(!__is_trivially_constructible(D));
+
+SA(__is_trivially_copyable(int));
+SA(!__is_trivially_copyable(volatile int));
index c21a5c467726882e2ffcc651d07b28b535942450..c8613550ce61ef78c6a8188226088009cfa12318 100644 (file)
@@ -47,6 +47,8 @@ void test01()
 
   static_assert(test_property<is_trivially_copyable, 
                int>(true), "");
+  static_assert(test_property<is_trivially_copyable,
+               volatile int>(false), "");
   static_assert(test_property<is_trivially_copyable, 
                TType>(true), "");
   static_assert(test_property<is_trivially_copyable,