public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] testsuite: Fix up pr98920.c on non-glibc or old glibc targets [PR98920]
@ 2021-03-09 13:16 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-03-09 13:16 UTC (permalink / raw)
  To: gcc-patches

Hi!

Not all OSes have regex.h and not all OSes that do have REG_STARTEND macro support.
Conditionalize the test on that.

Tested on x86_64-linux without/with Martin's libsanitizer fix, committed to
trunk as obvious.

2021-03-09  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/98920
	* c-c++-common/asan/pr98920.c: Only include regex.h if the header
	exists.  If REG_STARTEND macro isn't defined, just return 0 from main
	instead of the actual test.

--- gcc/testsuite/c-c++-common/asan/pr98920.c.jj	2021-03-08 23:40:33.935447429 +0100
+++ gcc/testsuite/c-c++-common/asan/pr98920.c	2021-03-09 12:15:28.904809967 +0100
@@ -3,10 +3,13 @@
 
 #include <stdio.h>
 #include <sys/types.h>
+#if __has_include(<regex.h>)
 #include <regex.h>
+#endif
 
 int main(void)
 {
+#ifdef REG_STARTEND
     regex_t r;
     const char s[] = "ban\0ana";
     regmatch_t pmatch[10];
@@ -20,5 +23,6 @@ int main(void)
         return 3;
     }
     regfree(&r);
+#endif
     return 0;
 }

	Jakub


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-09 13:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 13:16 [committed] testsuite: Fix up pr98920.c on non-glibc or old glibc targets [PR98920] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).