bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 5/5] bison: pacify Sun C 5.12


From: Akim Demaille
Subject: Re: [PATCH 5/5] bison: pacify Sun C 5.12
Date: Tue, 22 Oct 2013 17:34:58 +0200

Le 22 oct. 2013 à 00:28, Paul Eggert <address@hidden> a écrit :

> * src/uniqstr.h (uniqstr_vsprintf): Use
> _GL_ATTRIBUTE_FORMAT_PRINTF (...)  instead of __attribute__
> ((__format__ (__printf__, ...))).  Otherwise, Sun C 5.12
> complains about an unknown attribute.

> diff --git a/src/uniqstr.h b/src/uniqstr.h
> index 006c10f..7ad52da 100644
> --- a/src/uniqstr.h
> +++ b/src/uniqstr.h
> @@ -33,7 +35,7 @@ uniqstr uniqstr_new (char const *str);
>    strings, use UNIQSTR_CONCAT, which is a convenient wrapper around
>    this function.  */
> uniqstr uniqstr_vsprintf (char const *format, ...)
> -  __attribute__ ((__format__ (__printf__, 1, 2)));
> +  _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2);
> 
> /* Two uniqstr values have the same value iff they are the same.  */
> # define UNIQSTR_EQ(Ustr1, Ustr2) (!!((Ustr1) == (Ustr2)))

Hi Paul,

Bison is already generating code to define __attribute__.
That's the code that was in glr.c, and which is now used
in yacc.c and lalr1.cc too:

# b4_attribute_define
# -------------------
# Provide portability for __attribute__.
m4_define([b4_attribute_define],
[#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later.  */
# if (! defined __GNUC__ || __GNUC__ < 2 \
      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
#  define __attribute__(Spec) /* empty */
# endif
#endif

I expect that you would recommend that we define YY_ATTRIBUTE,
YY_ATTRIBUTE_UNUSED and so forth instead?

I was about to push this for C++.

commit 0b8b807d003f813c4eb156fd57f90e542387ea77
Author: Akim Demaille <address@hidden>
Date:   Tue Oct 22 17:10:33 2013 +0200

    c++: use __attribute__((__pure__)) to avoid warnings
    
    Building C++ parsers with -Wsuggest-attribute=const and
    -Wsuggest-attribute=noreturn triggers warning in generated code.
    
    * data/lalr1.cc: Define __attribute__ if not supported.
    (debug_stream, debug_level): Flag as pure.

diff --git a/data/lalr1.cc b/data/lalr1.cc
index a378463..15c8a3c 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -183,14 +183,14 @@ b4_location_define])])[
 
 #if ]b4_api_PREFIX[DEBUG
     /// The current debugging stream.
-    std::ostream& debug_stream () const;
+    std::ostream& debug_stream () const __attribute__((__pure__));
     /// Set the current debugging stream.
     void set_debug_stream (std::ostream &);
 
     /// Type for debugging levels.
     typedef int debug_level_type;
     /// The current debugging level.
-    debug_level_type debug_level () const;
+    debug_level_type debug_level () const __attribute__((__pure__));
     /// Set the current debugging level.
     void set_debug_level (debug_level_type l);
 #endif
@@ -418,6 +418,8 @@ m4_if(b4_prefix, [yy], [],
 # endif
 #endif
 
+]b4_attribute_define[
+
 ]b4_locations_if([dnl
 [#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
 ]b4_yylloc_default_define])[





reply via email to

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