diff options
author | ramana <ramana@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-19 08:12:31 +0000 |
---|---|---|
committer | ramana <ramana@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-19 08:12:31 +0000 |
commit | 77d6a623ca1ccd614007ad730fb3f5a3f04d193f (patch) | |
tree | cb8efc3d295c482a1090305d96edf16eb06c7b35 | |
parent | d8a9d052f259914d951f26cd206b97a4c1658275 (diff) | |
download | gcc-77d6a623ca1ccd614007ad730fb3f5a3f04d193f.tar.gz |
For Ian Bolton <ian.bolton@arm.com>
* tree-switch-conversion.c (gen_inbound_check): Ensure that the
type for the conditional has wide enough range.
* testsuite/g++.dg/pr44328.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163366 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr44328.C | 39 | ||||
-rw-r--r-- | gcc/tree-switch-conversion.c | 7 |
4 files changed, 53 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7e5e33069b..4711095729f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-08-19 Ian Bolton <ian.bolton@arm.com> + + * tree-switch-conversion.c (gen_inbound_check): Ensure that the + type for the conditional has wide enough range. + 2010-08-18 Uros Bizjak <ubizjak@gmail.com> PR target/45327 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index db26a97676e..afd8b999f6c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-08-19 Ian Bolton <ian.bolton@arm.com> + + * g++.dg/pr44328.C: New test. + 2010-08-19 Tobias Burnus <burnus@net-b.de> PR fortran/36158 diff --git a/gcc/testsuite/g++.dg/pr44328.C b/gcc/testsuite/g++.dg/pr44328.C new file mode 100644 index 00000000000..bbfe233340a --- /dev/null +++ b/gcc/testsuite/g++.dg/pr44328.C @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-c -O2 -Wextra" } */ +#define O_RDONLY (1<<0) +#define O_WRONLY (1<<1) +#define O_RDWR (O_RDONLY|O_WRONLY) +#define O_CREAT (1<<3) +#define O_TRUNC (1<<6) + +typedef enum { + OM_READ = 0, + OM_WRITE, + OM_READWRITE_NOCREATE, + OM_READWRITE_CREATE +} OpenMode; + +extern int open(const char *name, int mode); + +void open_file(const char *filename, const OpenMode rw) +{ + int mode = 0; + + switch( rw ) + { + case OM_WRITE: + mode = O_WRONLY|O_CREAT|O_TRUNC; + break; + case OM_READ: + mode = O_RDONLY; + break; + case OM_READWRITE_NOCREATE: + mode = O_RDWR; + break; + case OM_READWRITE_CREATE: + mode = O_RDWR|O_CREAT|O_TRUNC; + break; + } + + open( filename, mode ); +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index ed8b5ce5c0c..7072af8f5ab 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -96,6 +96,7 @@ eight) times the number of the actual switch branches. */ #include "gimple-pretty-print.h" #include "tree-dump.h" #include "timevar.h" +#include "langhooks.h" /* The main structure of the pass. */ struct switch_conv_info @@ -694,9 +695,11 @@ gen_inbound_check (gimple swtch) /* Make sure we do not generate arithmetics in a subrange. */ if (TREE_TYPE (TREE_TYPE (info.index_expr))) - utype = unsigned_type_for (TREE_TYPE (TREE_TYPE (info.index_expr))); + utype = lang_hooks.types.type_for_mode + (TYPE_MODE (TREE_TYPE (TREE_TYPE (info.index_expr))), 1); else - utype = unsigned_type_for (TREE_TYPE (info.index_expr)); + utype = lang_hooks.types.type_for_mode + (TYPE_MODE (TREE_TYPE (info.index_expr)), 1); /* (end of) block 0 */ gsi = gsi_for_stmt (info.arr_ref_first); |