diff options
author | Marek Polacek <polacek@redhat.com> | 2015-03-27 16:46:44 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-03-27 16:46:44 +0000 |
commit | 5964a3a67219410fffc9c108ac92b838af6c09ea (patch) | |
tree | cfea32e2ad3b2887f553f3e549bb6d48275c8d67 /gcc | |
parent | 0b7dccc63e31d11c2f129e569d06cef8c33d2921 (diff) | |
download | gcc-5964a3a67219410fffc9c108ac92b838af6c09ea.zip gcc-5964a3a67219410fffc9c108ac92b838af6c09ea.tar.gz gcc-5964a3a67219410fffc9c108ac92b838af6c09ea.tar.bz2 |
re PR c++/65556 (ICE: verify_gimple failed (type precision mismatch in switch statement))
PR c++/65556
* semantics.c (finish_switch_cond): If the unlowered type is not an
enum, use the type of the condition.
* c-c++-common/pr65556.c: New test.
From-SVN: r221738
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr65556.c | 23 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index baed6e1..9a3324f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-27 Marek Polacek <polacek@redhat.com> + + PR c++/65556 + * semantics.c (finish_switch_cond): If the unlowered type is not an + enum, use the type of the condition. + 2015-03-27 Jason Merrill <jason@redhat.com> PR c++/65509 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f325e41..74af7e8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1165,6 +1165,8 @@ finish_switch_cond (tree cond, tree switch_stmt) } /* We want unlowered type here to handle enum bit-fields. */ orig_type = unlowered_expr_type (cond); + if (TREE_CODE (orig_type) != ENUMERAL_TYPE) + orig_type = TREE_TYPE (cond); if (cond != error_mark_node) { /* Warn if the condition has boolean value. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1adea5..a586309 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-27 Marek Polacek <polacek@redhat.com> + + PR c++/65556 + * c-c++-common/pr65556.c: New test. + 2015-03-27 Jan Hubicka <hubicka@ucw.cz> PR ipa/65600 diff --git a/gcc/testsuite/c-c++-common/pr65556.c b/gcc/testsuite/c-c++-common/pr65556.c new file mode 100644 index 0000000..c6729a1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr65556.c @@ -0,0 +1,23 @@ +/* PR c++/65556 */ +/* { dg-do compile } */ + +struct S +{ + long l: 1; + long l2: 41; + unsigned long ul: 1; + unsigned long ul2: 41; +} s; + +void +fn () +{ + switch (s.l) + case 0:; + switch (s.ul) + case 0:; + switch (s.l2) + case 0:; + switch (s.ul2) + case 0:; +} |