+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>
PR target/25947
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
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 [lindex $status 0]
if { $status == 0 } then {
#define HASH_SIZE 32749
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 *srcdir;
FILE *outfile;
abort ();
if (!mi)
mi = 1;
- if (mi <= 32)
+ if (mi > 32)
+ ma = 64;
+ else if (mi > 16 || !short_enums)
ma = 32;
+ else if (mi > 8)
+ ma = 16;
else
- ma = 64;
+ ma = 8;
break;
default:
abort ();
output_one = 1;
limidx = atoi (optarg);
break;
+ case 'e':
+ short_enums = 1;
+ i--;
+ break;
default:
fprintf (stderr, "unrecognized option %s\n", argv[i]);
goto usage;
{
usage:
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]);
return 1;
}
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
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 [lindex $status 0]
if { $status == 0 } then {
#define HASH_SIZE 32749
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 *srcdir;
FILE *outfile;
abort ();
if (!mi)
mi = 1;
- if (mi <= 32)
+ if (mi > 32)
+ ma = 64;
+ else if (mi > 16 || !short_enums)
ma = 32;
+ else if (mi > 8)
+ ma = 16;
else
- ma = 64;
+ ma = 8;
break;
default:
abort ();
output_one = 1;
limidx = atoi (optarg);
break;
+ case 'e':
+ short_enums = 1;
+ i--;
+ break;
default:
fprintf (stderr, "unrecognized option %s\n", argv[i]);
goto usage;
{
usage:
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]);
return 1;
}
}
}
}
+
+# 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
+}
+