emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct byte compiler error/warning positions. The solution!


From: Alan Mackenzie
Subject: Re: Correct byte compiler error/warning positions. The solution!
Date: Mon, 29 Nov 2021 19:16:26 +0000

Hello, Robert.

On Mon, Nov 29, 2021 at 14:24:47 +0100, Robert Pluim wrote:
> >>>>> On Mon, 29 Nov 2021 11:50:19 +0000, Alan Mackenzie <acm@muc.de> said:
>     Alan> Anyhow, I've committed the current state in the new branch
>     Alan> scratch/correct-warning-pos.  It should build and run OK, although I
>     Alan> haven't tried it out with native compilation, yet.  It is marginally
>     Alan> slower than master.  Maybe we can merge it into master some time for
>     Alan> Emacs 29.

> "Thou shalt listen to Eli's warnings about '==', else your branch
> shall not compile"

:-)

> ./configure --enable-check-lisp-object-type --enable-checking

> make[1]: Entering directory '/home/rpluim/repos/emacs-pos/src'
>   CC       dispnew.o
> In file included from dispnew.c:27:
> lisp.h: In function ‘EQ’:
> lisp.h:385:40: error: invalid operands to binary == (have ‘Lisp_Object’ and 
> ‘Lisp_Object’)
>   385 |         ? (XSYMBOL_WITH_POS((x)))->sym == (y)          \
>       |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~
>       |                                  |
>       |                                  Lisp_Object
> lisp.h:1329:10: note: in expansion of macro ‘lisp_h_EQ’
>  1329 |   return lisp_h_EQ (x, y);
>       |          ^~~~~~~~~
> lisp.h:388:15: error: invalid operands to binary == (have ‘Lisp_Object’ and 
> ‘Lisp_Object’)
>   387 |           && ((XSYMBOL_WITH_POS((x)))->sym                   \
>       |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                                      |
>       |                                      Lisp_Object
>   388 |               == (XSYMBOL_WITH_POS((y)))->sym)               \
>       |               ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                                         |
>       |                                         Lisp_Object
> lisp.h:1329:10: note: in expansion of macro ‘lisp_h_EQ’
>  1329 |   return lisp_h_EQ (x, y);
>       |          ^~~~~~~~~
> lisp.h:391:18: error: invalid operands to binary == (have ‘Lisp_Object’ and 
> ‘Lisp_Object’)
>   391 |          && ((x) == ((XSYMBOL_WITH_POS ((y)))->sym))))))
>       |                  ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                                              |
>       |                                              Lisp_Object
> lisp.h:1329:10: note: in expansion of macro ‘lisp_h_EQ’
>  1329 |   return lisp_h_EQ (x, y);
>       |          ^~~~~~~~~
> In file included from dispnew.c:27:
> lisp.h:1330:1: warning: control reaches end of non-void function 
> [-Wreturn-type]
>  1330 | }
>       | ^
> make[1]: *** [Makefile:406: dispnew.o] Error 1

Yes.  I think the patch below will fix this.

I must admit, I didn't know about --enable-check-lisp-object-type.  When
I tried it out with the fixed lisp_h_EQ, I got lots of other warnings.


But this option generates slower code.  On a 20 second benchmark, the
code was ~0.5s slower than when compiled without the option.  This
probably shouldn't happen, and I don't know why it does.

I need to tidy up the backslashes too.

Anyhow, here's the patch which at least keeps the compiler messages as
warnings:



diff --git a/src/lisp.h b/src/lisp.h
index 08013e94d1..00d9843d6a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -366,7 +366,7 @@ #define LISP_WORDS_ARE_POINTERS (EMACS_INT_MAX == 
INTPTR_MAX)
 
 #define lisp_h_PSEUDOVECTORP(a,code)                            \
   (lisp_h_VECTORLIKEP((a)) &&                                   \
-   ((XUNTAG ((a), Lisp_Vectorlike, union vectorlike_header)->size       \
+   ((XUNTAG ((a), Lisp_Vectorlike, union vectorlike_header)->size     \
      & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))                    \
     == (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))))
 
@@ -382,13 +382,13 @@ #define lisp_h_EQ(x, y) ((XLI ((x)) == XLI ((y)))       \
   || (symbols_with_pos_enabled    \
   && (SYMBOL_WITH_POS_P ((x))                        \
       ? BARE_SYMBOL_P ((y))                               \
-        ? (XSYMBOL_WITH_POS((x)))->sym == (y)          \
+        ? XLI (XSYMBOL_WITH_POS((x))->sym) == XLI (y)           \
         : SYMBOL_WITH_POS_P((y))                       \
-          && ((XSYMBOL_WITH_POS((x)))->sym                   \
-              == (XSYMBOL_WITH_POS((y)))->sym)               \
+          && (XLI (XSYMBOL_WITH_POS((x))->sym)                   \
+              == XLI (XSYMBOL_WITH_POS((y))->sym))               \
       : (SYMBOL_WITH_POS_P ((y))                     \
          && BARE_SYMBOL_P ((x))                           \
-         && ((x) == ((XSYMBOL_WITH_POS ((y)))->sym))))))
+         && (XLI (x) == XLI ((XSYMBOL_WITH_POS ((y)))->sym))))))
 
 #define lisp_h_FIXNUMP(x) \
    (! (((unsigned) (XLI (x) >> (USE_LSB_TAG ? 0 : FIXNUM_BITS)) \

> Robert
> -- 

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]