Some tests for PR71151 assume that the target MCU has a 3-byte PC. The tests
are failing because the simulator (avrtest) rejects to load the respective
executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128 which has only
flash of 128KiB and only a 2-byte PC.
Hence the tests have to be skipped if the target MCU has no 3-byte PC, hence a
new dg-require-effective-target proc supporting "avr_3byte_pc".
I added the new proc right after the last check_effective_target_arm_*** so
that the test is in ASCII collating order.
Ok for trunk and v6?
Johann
gcc/testsuite/
PR target/71151
* lib/target-supports.exp (check_effective_target_avr_3byte_pc):
New proc.
* gcc.target/avr/pr71151-5.c: Remove code for __AVR_2_BYTE_PC__.
Use dg-require-effective-target avr_3byte_pc.
* gcc.target/avr/pr71151-6.c: Same.
* gcc.target/avr/pr71151-7.c: Same.
* gcc.target/avr/pr71151-8.c: Same.
Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp (revision 237587)
+++ testsuite/lib/target-supports.exp (working copy)
@@ -3588,6 +3588,16 @@ proc check_effective_target_arm_prefer_l
} "-O2 -mthumb" ]
}
+# Return 1 if this is an AVR target with a 3-byte PC.
+
+proc check_effective_target_avr_3byte_pc { } {
+ return [ check_no_compiler_messages avr_3byte_pc assembly {
+ #if !defined(__AVR_3_BYTE_PC__)
+ #error !__AVR_3_BYTE_PC__
+ #endif
+ }]
+}
+
# Return 1 if this is a PowerPC target supporting -meabi.
proc check_effective_target_powerpc_eabi_ok { } {
Index: testsuite/gcc.target/avr/pr71151-5.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-5.c (revision 237587)
+++ testsuite/gcc.target/avr/pr71151-5.c (working copy)
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x20000" } */
+/* { dg-require-effective-target avr_3byte_pc } */
/* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte
flash address for loading jump table entry and a jump table entry
@@ -11,10 +12,6 @@
int main()
{
- /* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
- exit(0);
-#else
foo(5);
if (y != 37)
abort();
@@ -26,5 +23,4 @@ int main()
foo(7);
if (y != 98)
abort();
-#endif
}
Index: testsuite/gcc.target/avr/pr71151-6.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-6.c (revision 237587)
+++ testsuite/gcc.target/avr/pr71151-6.c (working copy)
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x20000" } */
+/* { dg-require-effective-target avr_3byte_pc } */
/* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte
flash address for loading jump table entry and a jump table entry
@@ -11,10 +12,6 @@
int main()
{
- /* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
- exit(0);
-#else
foo(5);
if (y != 37)
abort();
@@ -26,5 +23,4 @@ int main()
foo(7);
if (y != 98)
abort();
-#endif
}
Index: testsuite/gcc.target/avr/pr71151-7.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-7.c (revision 237587)
+++ testsuite/gcc.target/avr/pr71151-7.c (working copy)
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x1fffa" } */
+/* { dg-require-effective-target avr_3byte_pc } */
/* Make sure jumptables work properly if placed straddling 128 KB i.e
some entries below 128 KB and some above it, with relaxation disabled. */
@@ -9,10 +10,6 @@
int main()
{
- /* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
- exit(0);
-#else
foo(5);
if (y != 37)
abort();
@@ -24,5 +21,4 @@ int main()
foo(7);
if (y != 98)
abort();
-#endif
}
Index: testsuite/gcc.target/avr/pr71151-8.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-8.c (revision 237587)
+++ testsuite/gcc.target/avr/pr71151-8.c (working copy)
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x1fffa" } */
+/* { dg-require-effective-target avr_3byte_pc } */
/* Make sure jumptables work properly if placed straddling 128 KB i.e
some entries below 128 KB and some above it, with relaxation disabled. */
@@ -9,10 +10,6 @@
int main()
{
- /* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
- exit(0);
-#else
foo(5);
if (y != 37)
abort();
@@ -24,5 +21,4 @@ int main()
foo(7);
if (y != 98)
abort();
-#endif
}