From 37d0ffd54d7614d3da100e974e5bfc43ff6c8503 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sat, 30 Jun 2018 08:09:26 +0000 Subject: [PATCH] [testsuite/guality] Don't use attribute used in pr45882.c for -O0 2018-06-30 Tom de Vries * gcc.dg/guality/guality.exp (guality_transform_options): New proc. (toplevel): Apply guality_transform_options on DG_TORTURE_OPTIONS and LTO_TORTURE_OPTIONS. * gcc.dg/guality/prevent-optimization.h: New file. * gcc.dg/guality/pr45882.c: Include prevent-optimization.h. (a): Replace __attribute__((used)) with ATTRIBUTE_USED. From-SVN: r262270 --- gcc/testsuite/ChangeLog | 9 ++++++ gcc/testsuite/gcc.dg/guality/guality.exp | 23 +++++++++++++++ gcc/testsuite/gcc.dg/guality/pr45882.c | 4 ++- .../gcc.dg/guality/prevent-optimization.h | 28 +++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/guality/prevent-optimization.h diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da2abc1937e..aa05ce74712 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2018-06-30 Tom de Vries + + * gcc.dg/guality/guality.exp (guality_transform_options): New proc. + (toplevel): Apply guality_transform_options on DG_TORTURE_OPTIONS and + LTO_TORTURE_OPTIONS. + * gcc.dg/guality/prevent-optimization.h: New file. + * gcc.dg/guality/pr45882.c: Include prevent-optimization.h. + (a): Replace __attribute__((used)) with ATTRIBUTE_USED. + 2018-06-30 Tom de Vries * gcc.dg/guality/pr45882.c (foo): Use relative line numbers. diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp index 04e889caa2f..d9994341477 100644 --- a/gcc/testsuite/gcc.dg/guality/guality.exp +++ b/gcc/testsuite/gcc.dg/guality/guality.exp @@ -48,6 +48,28 @@ if ![info exists ::env(GUALITY_GDB_NAME)] { } report_gdb $::env(GUALITY_GDB_NAME) [info script] +proc guality_transform_options { args } { + set res [list] + foreach opt [lindex $args 0] { + # + if { ! [regexp -- "-O0" $opt] } { + set opt "$opt -DPREVENT_OPTIMIZATION" + } + lappend res $opt + } + + return $res +} + +global DG_TORTURE_OPTIONS +set guality_dg_torture_options [guality_transform_options $DG_TORTURE_OPTIONS] +set guality_lto_torture_options [guality_transform_options $LTO_TORTURE_OPTIONS] +torture-init +set-torture-options \ + $guality_dg_torture_options \ + [list {}] \ + $guality_lto_torture_options + if {[check_guality " #include \"$srcdir/$subdir/guality.h\" volatile long int varl = 6; @@ -65,4 +87,5 @@ if [info exists guality_gdb_name] { unsetenv GUALITY_GDB_NAME } +torture-finish dg-finish diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c index 02d74389ea0..3e60a93a2d8 100644 --- a/gcc/testsuite/gcc.dg/guality/pr45882.c +++ b/gcc/testsuite/gcc.dg/guality/pr45882.c @@ -2,8 +2,10 @@ /* { dg-do run } */ /* { dg-options "-g" } */ +#include "prevent-optimization.h" + extern void abort (void); -int a[1024] __attribute__((used)); +int a[1024] ATTRIBUTE_USED; volatile short int v; __attribute__((noinline,noclone,used)) int diff --git a/gcc/testsuite/gcc.dg/guality/prevent-optimization.h b/gcc/testsuite/gcc.dg/guality/prevent-optimization.h new file mode 100644 index 00000000000..0ef84a3d9c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/prevent-optimization.h @@ -0,0 +1,28 @@ +/* Copyright (C) 2018 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef PREVENT_OPTIMIZATION_H +#define PREVENT_OPTIMIZATION_H + +#ifdef PREVENT_OPTIMIZATION +#define ATTRIBUTE_USED __attribute__((used)) +#else +#define ATTRIBUTE_USED +#endif + +#endif -- 2.30.2