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.

From-SVN: r163366
This commit is contained in:
Ian Bolton 2010-08-19 08:12:31 +00:00 committed by Ramana Radhakrishnan
parent d76799c7f0
commit f096c02afc
4 changed files with 53 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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 );
}

View File

@ -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);