aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-01-16 09:46:29 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-01-16 09:46:29 +0000
commitbe2b548394a3d0998cf7fff5e9d85fcecd22d5f7 (patch)
treecbd5804a6e2588513cf6180a869baff17ff233c2 /gcc
parenteb1387a0511b0b71c901c7a9458cea1cc2f911c4 (diff)
downloadgcc-be2b548394a3d0998cf7fff5e9d85fcecd22d5f7.zip
gcc-be2b548394a3d0998cf7fff5e9d85fcecd22d5f7.tar.gz
gcc-be2b548394a3d0998cf7fff5e9d85fcecd22d5f7.tar.bz2
re PR c++/33819 (Miscompiled shift of C++ bitfield)
2008-01-16 Richard Guenther <rguenther@suse.de> PR c++/33819 * typeck.c (is_bitfield_expr_with_lowered_type): Recurse for conversions to type variants. * g++.dg/torture/pr33819.C: New testcase. From-SVN: r131569
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr33819.C22
4 files changed, 40 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8582460..030232b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-16 Richard Guenther <rguenther@suse.de>
+
+ PR c++/33819
+ * typeck.c (is_bitfield_expr_with_lowered_type): Recurse
+ for conversions to type variants.
+
2008-01-15 Andreas Tobler <a.tobler@schweiz.org>
* parser.c (cp_parser_template_parameter): Fix C90 issue with mixing
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 50a844a..6557637 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1445,6 +1445,13 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
return DECL_BIT_FIELD_TYPE (field);
}
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (exp, 0)))
+ == TYPE_MAIN_VARIANT (TREE_TYPE (exp)))
+ return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 0));
+ /* Fallthrough. */
+
default:
return NULL_TREE;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b69ff98..e2748361 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2008-01-16 Richard Guenther <rguenther@suse.de>
+ PR c++/33819
+ * g++.dg/torture/pr33819.C: New testcase.
+
+2008-01-16 Richard Guenther <rguenther@suse.de>
+
PR c/34768
* gcc.c-torture/execute/pr34768-1.c: New testcase.
* gcc.c-torture/execute/pr34768-2.c: Likewise.
diff --git a/gcc/testsuite/g++.dg/torture/pr33819.C b/gcc/testsuite/g++.dg/torture/pr33819.C
new file mode 100644
index 0000000..a2f868d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr33819.C
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+class s
+{
+public:
+ s(long long aa) : a(aa), i1(0) { }
+ long long id() const { return (this->a << 16) >> 16; }
+ bool operator< (s sv) { return this->a < sv.id(); }
+private:
+ long long a : 48;
+ int i1 : 16;
+};
+s g(1);
+extern "C" void abort (void);
+int
+main(int, char**)
+{
+ if (g < (1LL << 38) - 1)
+ return 0;
+ abort ();
+}
+