]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
deref-before-check-pr113253.c: Fix bogus warnings on lp32
authorJonathan Yong <10walls@gmail.com>
Mon, 7 Apr 2025 15:40:05 +0000 (15:40 +0000)
committerJonathan Yong <10walls@gmail.com>
Wed, 9 Apr 2025 14:08:26 +0000 (14:08 +0000)
Warnings about pointer sizes cause the test to fail
incorrectly. A dummy return value is also added to
set_marker_internal for completeness to suppress a
-Wreturn-type warning even though gcc does not issue
it by default.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/testsuite/ChangeLog:

PR analyzer/113253
* gcc.dg/analyzer/deref-before-check-pr113253.c:
(ptrdiff_t): use stddef.h type.
(uintptr_t): ditto.
(EMACS_INT): ditto.
(set_marker_internal): Add dummy 0 to suppress -Wreturn-type.

gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c

index d9015accd6ab3191560315dde8fa59dedec19ab5..1890312cc1ab9105966eca5923c4bc09c1cde64d 100644 (file)
@@ -5,12 +5,12 @@
 
 /* { dg-additional-options "-O2 -g" } */
 
-typedef long int ptrdiff_t;
-typedef unsigned long int uintptr_t;
-typedef long int EMACS_INT;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
+typedef __PTRDIFF_TYPE__ EMACS_INT;
 enum
 {
-  EMACS_INT_WIDTH = 64,
+  EMACS_INT_WIDTH = sizeof(EMACS_INT) * 8,
   VALBITS = EMACS_INT_WIDTH - 3,
 };
 typedef struct Lisp_X* Lisp_Word;
@@ -151,4 +151,5 @@ set_marker_internal(Lisp_Object position, Lisp_Object buffer)
   struct buffer* b = live_buffer(buffer);
   if (NILP(position) || (MARKERP(position) && !XMARKER(position)->buffer) || !b) /* { dg-bogus "Wanalyzer-deref-before-check" } */
     unchain_marker();
+  return 0;
 }