+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.
}
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;
unsetenv GUALITY_GDB_NAME
}
+torture-finish
dg-finish
/* { 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
--- /dev/null
+/* 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