Commit efe5e271 by Paul Brook Committed by Paul Brook

struct-layout-1.exp: Pass -e to generator program on short-enum targets.

2006-01-26  Paul Brook  <paul@codesourcery.com>

	* gcc.dg/compat/struct-layout-1.exp: Pass -e to generator program
	on short-enum targets.
	* gcc.dg/compat/struct-layout-1_generate.c (short_enums): New
	variable.
	(generate_fields): Use short_enums.
	(main): Set short_enums.  Document -e.
	* g++.dg/compat/struct-layout-1.exp: Pass -e to generator program
	on short-enum targets.
	* g++.dg/compat/struct-layout-1_generate.c (short_enums): New
	variable.
	(generate_fields): Use short_enums.
	(main): Set short_enums.  Document -e.
	* lib/target-supports.exp (check_effective_target_short_enums): New.

From-SVN: r110247
parent ee45f679
2006-01-26 Paul Brook <paul@codesourcery.com>
* gcc.dg/compat/struct-layout-1.exp: Pass -e to generator program
on short-enum targets.
* gcc.dg/compat/struct-layout-1_generate.c (short_enums): New
variable.
(generate_fields): Use short_enums.
(main): Set short_enums. Document -e.
* g++.dg/compat/struct-layout-1.exp: Pass -e to generator program
on short-enum targets.
* g++.dg/compat/struct-layout-1_generate.c (short_enums): New
variable.
(generate_fields): Use short_enums.
(main): Set short_enums. Document -e.
* lib/target-supports.exp (check_effective_target_short_enums): New.
2006-01-26 Hans-Peter Nilsson <hp@axis.com> 2006-01-26 Hans-Peter Nilsson <hp@axis.com>
PR target/25947 PR target/25947
...@@ -138,6 +138,9 @@ if { $status == 0 } then { ...@@ -138,6 +138,9 @@ if { $status == 0 } then {
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then { if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
set generator_args "$generator_args -n 15000" set generator_args "$generator_args -n 15000"
} }
if [check_effective_target_short_enums] then {
set generator_args "-e $generator_args"
}
set status [remote_exec host "$generator $generator_args"] set status [remote_exec host "$generator $generator_args"]
set status [lindex $status 0] set status [lindex $status 0]
if { $status == 0 } then { if { $status == 0 } then {
......
...@@ -478,7 +478,7 @@ struct types attrib_array_types[] = { ...@@ -478,7 +478,7 @@ struct types attrib_array_types[] = {
#define HASH_SIZE 32749 #define HASH_SIZE 32749
static struct entry *hash_table[HASH_SIZE]; static struct entry *hash_table[HASH_SIZE];
static int idx, limidx, output_one; static int idx, limidx, output_one, short_enums;
static const char *destdir; static const char *destdir;
static const char *srcdir; static const char *srcdir;
FILE *outfile; FILE *outfile;
...@@ -1368,10 +1368,14 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, ...@@ -1368,10 +1368,14 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
abort (); abort ();
if (!mi) if (!mi)
mi = 1; mi = 1;
if (mi <= 32) if (mi > 32)
ma = 64;
else if (mi > 16 || !short_enums)
ma = 32; ma = 32;
else if (mi > 8)
ma = 16;
else else
ma = 64; ma = 8;
break; break;
default: default:
abort (); abort ();
...@@ -1533,6 +1537,10 @@ main (int argc, char **argv) ...@@ -1533,6 +1537,10 @@ main (int argc, char **argv)
output_one = 1; output_one = 1;
limidx = atoi (optarg); limidx = atoi (optarg);
break; break;
case 'e':
short_enums = 1;
i--;
break;
default: default:
fprintf (stderr, "unrecognized option %s\n", argv[i]); fprintf (stderr, "unrecognized option %s\n", argv[i]);
goto usage; goto usage;
...@@ -1555,7 +1563,7 @@ main (int argc, char **argv) ...@@ -1555,7 +1563,7 @@ main (int argc, char **argv)
{ {
usage: usage:
fprintf (stderr, "Usage:\n\ fprintf (stderr, "Usage:\n\
%s [-s srcdir -d destdir] [-n count] [-i idx]\n\ %s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
Either -s srcdir -d destdir or -i idx must be used\n", argv[0]); Either -s srcdir -d destdir or -i idx must be used\n", argv[0]);
return 1; return 1;
} }
......
...@@ -99,6 +99,9 @@ if { $status == 0 } then { ...@@ -99,6 +99,9 @@ if { $status == 0 } then {
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then { if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
set generator_args "$generator_args -n 15000" set generator_args "$generator_args -n 15000"
} }
if [check_effective_target_short_enums] then {
set generator_args "-e $generator_args"
}
set status [remote_exec host "$generator $generator_args"] set status [remote_exec host "$generator $generator_args"]
set status [lindex $status 0] set status [lindex $status 0]
if { $status == 0 } then { if { $status == 0 } then {
......
...@@ -718,7 +718,7 @@ struct entry ...@@ -718,7 +718,7 @@ struct entry
#define HASH_SIZE 32749 #define HASH_SIZE 32749
static struct entry *hash_table[HASH_SIZE]; static struct entry *hash_table[HASH_SIZE];
static int idx, limidx, output_one; static int idx, limidx, output_one, short_enums;
static const char *destdir; static const char *destdir;
static const char *srcdir; static const char *srcdir;
FILE *outfile; FILE *outfile;
...@@ -1759,10 +1759,14 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, ...@@ -1759,10 +1759,14 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
abort (); abort ();
if (!mi) if (!mi)
mi = 1; mi = 1;
if (mi <= 32) if (mi > 32)
ma = 64;
else if (mi > 16 || !short_enums)
ma = 32; ma = 32;
else if (mi > 8)
ma = 16;
else else
ma = 64; ma = 8;
break; break;
default: default:
abort (); abort ();
...@@ -1935,6 +1939,10 @@ main (int argc, char **argv) ...@@ -1935,6 +1939,10 @@ main (int argc, char **argv)
output_one = 1; output_one = 1;
limidx = atoi (optarg); limidx = atoi (optarg);
break; break;
case 'e':
short_enums = 1;
i--;
break;
default: default:
fprintf (stderr, "unrecognized option %s\n", argv[i]); fprintf (stderr, "unrecognized option %s\n", argv[i]);
goto usage; goto usage;
...@@ -1957,7 +1965,7 @@ main (int argc, char **argv) ...@@ -1957,7 +1965,7 @@ main (int argc, char **argv)
{ {
usage: usage:
fprintf (stderr, "Usage:\n\ fprintf (stderr, "Usage:\n\
%s [-s srcdir -d destdir] [-n count] [-i idx]\n\ %s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
Either -s srcdir -d destdir or -i idx must be used\n", argv[0]); Either -s srcdir -d destdir or -i idx must be used\n", argv[0]);
return 1; return 1;
} }
......
...@@ -1658,3 +1658,42 @@ proc is-effective-target-keyword { arg } { ...@@ -1658,3 +1658,42 @@ proc is-effective-target-keyword { arg } {
} }
} }
} }
# Return 1 if target default to short enums
proc check_effective_target_short_enums { } {
global et_short_enums_saved
global et_short_enums_target_name
if { ![info exists et_short_enums_target_name] } {
set et_short_enums_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_short_enums_target_name } {
verbose "check_effective_target_short_enums: `$et_short_enums_target_name'" 2
set et_short_enums_target_name $current_target
if [info exists et_short_enums_saved] {
verbose "check_effective_target_short_enums: removing cached result" 2
unset et_short_enums_saved
}
}
if [info exists et_short_enums_saved] {
verbose "check_effective_target_short_enums: using cached result" 2
} else {
verbose "check_effective_target_short_enums: compiling source" 2
# PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
# bitfields, but let's stick to the example code from the docs.
set et_short_enums_saved \
[string match "" [get_compiler_messages short_enums assembly {
enum foo { bar };
int s[sizeof (enum foo) == 1 ? 1 : -1];
} ]]
}
verbose "check_effective_target_short_enums: returning $et_short_enums_saved" 2
return $et_short_enums_saved
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment