diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2005-11-02 02:49:24 +0000 |
---|---|---|
committer | Hans-Peter Nilsson <hp@gcc.gnu.org> | 2005-11-02 02:49:24 +0000 |
commit | edc5687ec1613e9d2f92f30a9def936689a79d39 (patch) | |
tree | 169b6d1d625faf6d958a1919b004b1afe2a9efd3 /gcc/testsuite | |
parent | aa5c7673b84fbcecbe6301d6df6a0849dffbcb02 (diff) | |
download | gcc-edc5687ec1613e9d2f92f30a9def936689a79d39.zip gcc-edc5687ec1613e9d2f92f30a9def936689a79d39.tar.gz gcc-edc5687ec1613e9d2f92f30a9def936689a79d39.tar.bz2 |
* lib/target-supports.exp
(check_effective_target_pcc_bitfield_type_matters): New proc.
* gcc.dg/bitfld-3.c: Gate on target pcc_bitfield_type_matters.
From-SVN: r106375
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/bitfld-3.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 40 |
3 files changed, 45 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 079e1e6..2783243 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2005-11-02 Hans-Peter Nilsson <hp@axis.com> + * lib/target-supports.exp + (check_effective_target_pcc_bitfield_type_matters): New proc. + * gcc.dg/bitfld-3.c: Gate on target pcc_bitfield_type_matters. + * lib/target-supports.exp (check_effective_default_packed): New proc. * g++.dg/ext/packed3.C, g++.dg/ext/packed8.C, g++.dg/other/crash-4.C: Gate expected errors on target ! default_packed. diff --git a/gcc/testsuite/gcc.dg/bitfld-3.c b/gcc/testsuite/gcc.dg/bitfld-3.c index 3843acb..5207bed 100644 --- a/gcc/testsuite/gcc.dg/bitfld-3.c +++ b/gcc/testsuite/gcc.dg/bitfld-3.c @@ -1,5 +1,5 @@ /* Test for bitfield alignment in structs and unions. */ -/* { dg-do run } */ +/* { dg-do run { target pcc_bitfield_type_matters } } */ /* { dg-options "-O2" } */ extern void abort (void); diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index eac6658..3116c42 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -344,6 +344,46 @@ proc check_effective_target_default_packed { } { return $et_default_packed_saved } +# Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See +# documentation, where the test also comes from. + +proc check_effective_target_pcc_bitfield_type_matters { } { + global et_pcc_bitfield_type_matters_saved + global et_pcc_bitfield_type_matters_target_name + + if { ![info exists et_pcc_bitfield_type_matters_target_name] } { + set et_pcc_bitfield_type_matters_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_pcc_bitfield_type_matters_target_name } { + verbose "check_effective_target_pcc_bitfield_type_matters: `$et_pcc_bitfield_type_matters_target_name'" 2 + set et_pcc_bitfield_type_matters_target_name $current_target + if [info exists et_pcc_bitfield_type_matters_saved] { + verbose "check_effective_target_pcc_bitfield_type_matters: removing cached result" 2 + unset et_pcc_bitfield_type_matters_saved + } + } + + if [info exists et_pcc_bitfield_type_matters_saved] { + verbose "check_effective_target_pcc_bitfield_type_matters: using cached result" 2 + } else { + verbose "check_effective_target_pcc_bitfield_type_matters: 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_pcc_bitfield_type_matters_saved \ + [string match "" [get_compiler_messages pcc_bitfield_type_matters assembly { + struct foo1 { char x; char :0; char y; }; + struct foo2 { char x; int :0; char y; }; + int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1]; + } ]] + } + verbose "check_effective_target_pcc_bitfield_type_matters: returning $et_pcc_bitfield_type_matters_saved" 2 + return $et_pcc_bitfield_type_matters_saved +} + # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors # emitted, 0 otherwise. Whether a shared library can actually be built is # out of scope for this test. |