public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]
@ 2024-02-02 15:23 Rainer Orth
  2024-02-12 21:24 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2024-02-02 15:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: H.J. Lu

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

c-c++-common/pr103798-2.c FAILs on Solaris when compiled as C++:

FAIL: c-c++-common/pr103798-2.c  -std=gnu++14  scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c  -std=gnu++17  scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c  -std=gnu++20  scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c  -std=gnu++98  scan-assembler-not memchr

As H.J. analyzed in the PR, Solaris <string.h> declares std::memchr, not
memchr, which isn't treated as __builtin_memchr.

To avoid this, this patch declares memchr directly instead of including
<string.h>.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
i686-pc-linux-gnu.

Ok for trunk?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/testsuite:
	PR tree-optimization/113706
	* c-c++-common/pr103798-2.c (NULL): Define.
	(size_t, memchr): Declare instead of including <string.h>.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-testsuite-pr103798-2.patch --]
[-- Type: text/x-patch, Size: 660 bytes --]

# HG changeset patch
# Parent  943813561aef290adb442042f9c4fe9999cd82ee
testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]

diff --git a/gcc/testsuite/c-c++-common/pr103798-2.c b/gcc/testsuite/c-c++-common/pr103798-2.c
--- a/gcc/testsuite/c-c++-common/pr103798-2.c
+++ b/gcc/testsuite/c-c++-common/pr103798-2.c
@@ -1,7 +1,16 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -fdump-tree-optimized -save-temps" } */
 
-#include <string.h>
+#define NULL ((void *) 0)
+
+typedef __SIZE_TYPE__ size_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void *memchr (const void *, int, size_t);
+#ifdef __cplusplus
+}
+#endif
 
 __attribute__ ((weak))
 int

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-13 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 15:23 [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706] Rainer Orth
2024-02-12 21:24 ` Jason Merrill
2024-02-13 10:27   ` Rainer Orth
2024-02-13 20:04     ` Jason Merrill

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).