public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5765] [Committed] New testcase for C++/71792, bitfields and auto
@ 2021-12-03  8:17 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2021-12-03  8:17 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d82823454355f9d24dba51316145f84ae8d34ff7

commit r12-5765-gd82823454355f9d24dba51316145f84ae8d34ff7
Author: Andrew Pinski <apinski@marvell.com>
Date:   Fri Dec 3 08:13:32 2021 +0000

    [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.

Diff:
---
 gcc/testsuite/g++.dg/torture/pr71792.C | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gcc/testsuite/g++.dg/torture/pr71792.C b/gcc/testsuite/g++.dg/torture/pr71792.C
new file mode 100644
index 00000000000..607774d755d
--- /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;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-03  8:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03  8:17 [gcc r12-5765] [Committed] New testcase for C++/71792, bitfields and auto Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).