aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2021-12-03 08:13:32 +0000
committerAndrew Pinski <apinski@marvell.com>2021-12-03 08:17:03 +0000
commitd82823454355f9d24dba51316145f84ae8d34ff7 (patch)
tree7c86cb6b86bc915ac66ef97daf5bc0a2556e2339
parent66e157188bd2f789809e17e85f917534c9381599 (diff)
downloadgcc-d82823454355f9d24dba51316145f84ae8d34ff7.zip
gcc-d82823454355f9d24dba51316145f84ae8d34ff7.tar.gz
gcc-d82823454355f9d24dba51316145f84ae8d34ff7.tar.bz2
[Committed] New testcase for C++/71792, bitfields and auto
This testcase used to fail before GCC 6.4.0 due to the wrong type being used for auto when used with bitfields, the C++ front-end was using the "bitfield" type rather than the underlaying type. Committed the testcase after a quick check. PR c++/71792 gcc/testsuite/ChangeLog: * g++.dg/torture/pr71792.C: New test.
-rw-r--r--gcc/testsuite/g++.dg/torture/pr71792.C42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/torture/pr71792.C b/gcc/testsuite/g++.dg/torture/pr71792.C
new file mode 100644
index 0000000..607774d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr71792.C
@@ -0,0 +1,42 @@
+// { dg-do run { target c++11 } }
+// PR C++/71792
+
+class some_class
+{
+public:
+ unsigned int np : 4;
+ unsigned int nc : 8;
+ unsigned int nc0 : 1;
+};
+
+template<bool what>
+static void test_bug (const some_class &mp) {
+ if (what) {
+ int t = 0;
+ for (auto i = mp.nc0; i < mp.nc; i++) {
+ if (t != i) __builtin_abort ();
+ t++;
+ }
+ }
+}
+
+static void test_ok (const some_class &mp) {
+ int t = 0;
+ for (auto i = mp.nc0; i < mp.nc; i++) {
+ if (t != i) __builtin_abort ();
+ t++;
+ }
+}
+
+int main ()
+{
+ some_class mp;
+ mp.nc0 = 0;
+ mp.nc = 9;
+ mp.np = 3;
+
+ test_bug<true> (mp);
+ test_ok (mp);
+
+ return 0;
+}