From 81d3b8f7029f8790211628e308a766783193a8ef Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sun, 1 Jul 2018 15:54:48 +0000 Subject: [PATCH] [testsuite/guality] Prevent optimization of local in vla-1.c 2018-07-01 Tom de Vries * gcc.dg/guality/prevent-optimization.h (VOLATILE): Define. * gcc.dg/guality/vla-1.c (f1): Mark local vla a as VOLATILE. From-SVN: r262287 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/guality/prevent-optimization.h | 2 ++ gcc/testsuite/gcc.dg/guality/vla-1.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d24b0b4e430..b8b00f5f875 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-01 Tom de Vries + + * gcc.dg/guality/prevent-optimization.h (VOLATILE): Define. + * gcc.dg/guality/vla-1.c (f1): Mark local vla a as VOLATILE. + 2018-07-01 Tom de Vries * lib/gcc-dg.exp (get-absolute-line): Handle '.'. diff --git a/gcc/testsuite/gcc.dg/guality/prevent-optimization.h b/gcc/testsuite/gcc.dg/guality/prevent-optimization.h index 0ef84a3d9c8..57e945cafb4 100644 --- a/gcc/testsuite/gcc.dg/guality/prevent-optimization.h +++ b/gcc/testsuite/gcc.dg/guality/prevent-optimization.h @@ -21,8 +21,10 @@ along with GCC; see the file COPYING3. If not see #ifdef PREVENT_OPTIMIZATION #define ATTRIBUTE_USED __attribute__((used)) +#define VOLATILE volatile #else #define ATTRIBUTE_USED +#define VOLATILE #endif #endif diff --git a/gcc/testsuite/gcc.dg/guality/vla-1.c b/gcc/testsuite/gcc.dg/guality/vla-1.c index 264b9f3f92b..d281185c18c 100644 --- a/gcc/testsuite/gcc.dg/guality/vla-1.c +++ b/gcc/testsuite/gcc.dg/guality/vla-1.c @@ -2,6 +2,8 @@ /* { dg-do run } */ /* { dg-options "-g" } */ +#include "prevent-optimization.h" + void __attribute__((noinline)) bar (short *p) { @@ -12,7 +14,7 @@ bar (short *p) int __attribute__((noinline)) f1 (int i) { - char a[i + 1]; + VOLATILE char a[i + 1]; a[0] = 5; /* { dg-final { gdb-test .+1 "i" "5" } } */ return a[0]; /* { dg-final { gdb-test . "sizeof (a)" "6" } } */ } -- 2.30.2