diff --git a/gcc/testsuite/gcc.dg/visibility-22.c b/gcc/testsuite/gcc.dg/visibility-22.c
index e2b78d1c7fdedb8e91811b9b370089f4711e4e96..9123b350b2e4b00050e7b5a5f0233a3c84edbc45 100644
--- a/gcc/testsuite/gcc.dg/visibility-22.c
+++ b/gcc/testsuite/gcc.dg/visibility-22.c
@@ -3,6 +3,7 @@
 /* { dg-require-visibility "" } */
 /* { dg-require-effective-target weak_undefined } */
 /* { dg-options "-O2 -fPIC" { target fpic } } */
+/* { dg-add-options weak_undefined } */
 
 extern void foo () __attribute__((weak,visibility("hidden")));
 int
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 8a110f2d3bd1b3e0cc7d077f8db962e4113629f0..1d6cc6f8d88cb7f46d065d98fa7184fe52ebc44c 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -361,7 +361,7 @@ proc check_weak_available { } {
 proc add_options_for_weak_undefined { flags } {
     if { [istarget *-*-darwin*] } {
 	lappend flags "-Wl,-undefined,dynamic_lookup"
-	if { [istarget *-*-darwin[89]*] } {
+	if { [istarget *-*-darwin\[89\]*] } {
 	    lappend flags "-Wl,-flat_namespace"
 	}
     }
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c
index 20c420d7757af93be301940f44d9878353b3be4c..525e3bff0f1e11f154113702ecf4e58aae6b1340 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c
@@ -8,6 +8,7 @@
 /* { 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>