bug-bison
[Top][All Lists]
Advanced

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

Re: [PATCH 0/3] yacc: compute the best type for the state number


From: Akim Demaille
Subject: Re: [PATCH 0/3] yacc: compute the best type for the state number
Date: Sat, 5 Oct 2019 09:28:48 +0200

Hi Paul,

> Le 4 oct. 2019 à 07:02, Akim Demaille <address@hidden> a écrit :
> 
>>> Old compilers choke on the current code in master, we have to stop and 
>>> focus on this first.
>> 
>> I can help with that if you'll give me advice about how old to worry about 
>> (as long as it's not before GCC 3.4.3 :-).
> 
> There are several types of errors.  Some are due to your removing some casts, 
> and replacing them with pragmas.  Actually, I don't understand what you meant:
> 
>> /* Suppress bogus -Wconversion warnings from GCC.  */
>> #if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
>> # define YY_CONVERT_INT_BEGIN \
>>    _Pragma ("GCC diagnostic push") \
>>    _Pragma ("GCC diagnostic ignored \"-Wconversion\"")
>> # define YY_CONVERT_INT_END \
>>    _Pragma ("GCC diagnostic pop")
>> #else
>> # define YY_CONVERT_INT_BEGIN
>> # define YY_CONVERT_INT_END
>> #endif
>> 
>>    typedef yytype_int8 yy_state_num;
>>    int yystate;
>>    yy_state_num *yyssp;
>> 
>>  YY_CONVERT_INT_BEGIN
>>  *yyssp = yystate;
>>  YY_CONVERT_INT_END

I can't wait: these errors are blocking from me from pushing other changes that 
I was about to send.

This patch is trivial.  I still don't understand what the Pragma approach was 
buying us, but we can restore it afterwards.

commit 5709f94a91155149fd69479b3dd179de674935b7
Author: Akim Demaille <address@hidden>
Date:   Sat Oct 5 08:55:51 2019 +0200

    yacc.c: use casts instead of pragmas when losing integer width
    
    For instance with Clang 4, 8, etc.:
    
        input.c:1166:12: error: implicit conversion loses integer precision: 
'int' to 'yy_state_num' (aka 'signed char') [-Werror,-Wconversion]
          *yyssp = yystate;
                 ~ ^~~~~~~
    
    And GCC 8:
    
        input.c:1166:12: error: implicit conversion loses integer precision: 
'int' to 'yy_state_num' (aka 'signed char') [-Werror,-Wimplicit-int-conversion]
          *yyssp = yystate;
                 ~ ^~~~~~~
    
    * data/skeletons/yacc.c (YY_CONVERT_INT_BEGIN): Remove.
    Adjust callers.

diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index f3ef63fe..fdf4ba6d 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -468,18 +468,6 @@ typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ 
yy_state_num;
 
 ]b4_attribute_define[
 
-/* Suppress bogus -Wconversion warnings from GCC.  */
-#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
-# define YY_CONVERT_INT_BEGIN \
-    _Pragma ("GCC diagnostic push") \
-    _Pragma ("GCC diagnostic ignored \"-Wconversion\"")
-# define YY_CONVERT_INT_END \
-    _Pragma ("GCC diagnostic pop")
-#else
-# define YY_CONVERT_INT_BEGIN
-# define YY_CONVERT_INT_END
-#endif
-
 ]b4_parse_assert_if([[#ifdef NDEBUG
 # define YY_ASSERT(E) ((void) (0 && (E)))
 #else
@@ -1062,9 +1050,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
         if (yyesp == yyes_prev)
           {
             yyesp = *yyes;
-            YY_CONVERT_INT_BEGIN
-            *yyesp = yystate;
-            YY_CONVERT_INT_END
+            *yyesp = (yy_state_num) yystate;
           }
         else
           {
@@ -1077,9 +1063,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
                 YYDPRINTF ((stderr, "\n"));
                 return 2;
               }
-            YY_CONVERT_INT_BEGIN
-            *++yyesp = yystate;
-            YY_CONVERT_INT_END
+            *++yyesp = (yy_state_num) yystate;
           }
         YYDPRINTF ((stderr, " G%d", yystate));
       }
@@ -1542,9 +1526,7 @@ yynewstate:
 yysetstate:
   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
-  YY_CONVERT_INT_BEGIN
-  *yyssp = yystate;
-  YY_CONVERT_INT_END
+   *yyssp = (yy_state_num) yystate;
 
   if (yyss + yystacksize - 1 <= yyssp)
 #if !defined yyoverflow && !defined YYSTACK_RELOCATE




reply via email to

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