gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c
Rainer Orth 8443f42f05 testsuite: Fix weak_undefined handling on Darwin
The patch that introduced the weak_undefined effective-target keyword
and corresponding dg-add-options support

commit 378ec7b87a
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Mar 23 00:45:05 2023 -0300

    [testsuite] test for weak_undefined support and add options

badly broke the affected tests on macOS like so:

ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "
ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "

add_options_for_weak_undefined tries to call an non-existant proc "89".
Even after fixing this by escaping the brackets, two tests still failed to
link since they lacked the corresponding calls do dg-add-options
weak_undefined.

Tested on x86_64-apple-darwin20.6.0 and i386-pc-solaris2.11.

2023-03-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/testsuite:
	* lib/target-supports.exp (add_options_for_weak_undefined): Escape
	brackets.
	* gcc.dg/visibility-22.c: Add weak_undefined options.

	libgomp:
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c: Add
	weak_undefined options.
2023-03-28 10:40:05 +02:00

40 lines
848 B
C

/* Test 'nohost' clause via 'weak'.
{ dg-require-effective-target weak_undefined }
When the OpenACC 'routine' with 'nohost' clauses gets discarded, the weak symbol then resolves to 'NULL'.
*/
/* { dg-additional-sources routine-nohost-2_2.c } */
/* { dg-additional-options "-fno-inline" } for stable results regarding OpenACC 'routine'. */
/* { dg-add-options weak_undefined } */
#include <assert.h>
#include <openacc.h>
#pragma acc routine //nohost
__attribute__((weak))
extern int f1(int);
int main()
{
int x = -10;
#pragma acc serial copy(x)
/* { dg-warning {using .vector_length \(32\)., ignoring 1} "" { target openacc_nvidia_accel_selected } .-1 } */
{
if (f1)
x = f1(x);
else
x = 0;
}
if (acc_get_device_type() == acc_device_host)
assert(x == 0);
else
assert(x == -20);
return 0;
}