aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2018-06-30 08:09:26 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-06-30 08:09:26 +0000
commit37d0ffd54d7614d3da100e974e5bfc43ff6c8503 (patch)
tree5ef2f1da283d6f67a35140d26a71d37af322201b /gcc
parentf269206b1b9d10401e7afc99e37050892d26d014 (diff)
downloadgcc-37d0ffd54d7614d3da100e974e5bfc43ff6c8503.zip
gcc-37d0ffd54d7614d3da100e974e5bfc43ff6c8503.tar.gz
gcc-37d0ffd54d7614d3da100e974e5bfc43ff6c8503.tar.bz2
[testsuite/guality] Don't use attribute used in pr45882.c for -O0
2018-06-30 Tom de Vries <tdevries@suse.de> * 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/guality/guality.exp23
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr45882.c4
-rw-r--r--gcc/testsuite/gcc.dg/guality/prevent-optimization.h28
4 files changed, 63 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index da2abc1..aa05ce7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2018-06-30 Tom de Vries <tdevries@suse.de>
+ * 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 <tdevries@suse.de>
+
* gcc.dg/guality/pr45882.c (foo): Use relative line numbers.
* lib/gcc-dg.exp (dg-final): New proc.
* lib/gcc-gdb-test.exp (gdb-test): Add and handle additional line number
diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp
index 04e889c..d999434 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 02d7438..3e60a93 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 0000000..0ef84a3
--- /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
+<http://www.gnu.org/licenses/>. */
+
+#ifndef PREVENT_OPTIMIZATION_H
+#define PREVENT_OPTIMIZATION_H
+
+#ifdef PREVENT_OPTIMIZATION
+#define ATTRIBUTE_USED __attribute__((used))
+#else
+#define ATTRIBUTE_USED
+#endif
+
+#endif