This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: add #define to revert C99 inlining behaviour


On Fri, 2006-11-03 at 20:33 -0800, Mike Stump wrote:
> On Nov 3, 2006, at 8:03 PM, Andrew Pinski wrote:
> > On Fri, 2006-11-03 at 18:59 -0800, Geoffrey Keating wrote:
> >> Apparently it is 'controversial' that -std=c99 should implement C99.
> >>
> >> So, here is a #define.  You can switch it off, on again, off  
> >> again, on
> >> again, and so on, to your heart's delight.
> >
> > Didn't we agree on an option instead of a define inside GCC?
> 
> Here is my contribution...  The idea is that Mark can flip the  
> default for the switch in the 4.3 release branch, later, if he would  
> like to do that.
> 
> Also, I'll note, that we could put this into 4.2, with the default to  
> 0, to get people to fix their software 1 year earlier, if we wanted  
> to, this would lesson the hurt in 4.3 when it default to on.

I noticed in your patch it never defined flag_isoc99_inline.

This is what I would do untested and not fully there:
Doing diffs in .:
--- ./c-decl.c.~1~      2006-11-03 19:56:02.000000000 -0800
+++ ./c-decl.c  2006-11-03 20:24:33.000000000 -0800
@@ -62,12 +62,6 @@ Software Foundation, 51 Franklin Street,
 #include "langhooks-def.h"
 #include "pointer-set.h"
 
-/* Set this to 1 if you want the standard ISO C99 semantics of 'inline'
-   when you specify -std=c99 or -std=gnuc99, and to 0 if you want
-   behaviour compatible with the nonstandard semantics implemented by
-   GCC 2.95 through 4.2.  */
-#define WANT_C99_INLINE_SEMANTICS 1
-
 /* In grokdeclarator, distinguish syntactic contexts of declarators.
*/
 enum decl_context
 { NORMAL,                      /* Ordinary declaration */
@@ -1766,19 +1760,20 @@ merge_decls (tree newdecl, tree olddecl,
        }
     }
 
-#if WANT_C99_INLINE_SEMANTICS
   /* In c99, 'extern' declaration before (or after) 'inline' means this
      function is not DECL_EXTERNAL.  */
   if (TREE_CODE (newdecl) == FUNCTION_DECL
       && (DECL_DECLARED_INLINE_P (newdecl) 
          || DECL_DECLARED_INLINE_P (olddecl))
       && (!DECL_DECLARED_INLINE_P (newdecl) 
          || !DECL_DECLARED_INLINE_P (olddecl)
          || !DECL_EXTERNAL (olddecl))
        && DECL_EXTERNAL (newdecl)
-       && flag_isoc99)
+       && flag_isoc99_inline)
      DECL_EXTERNAL (newdecl) = 0;
-#endif /* WANT_C99_INLINE_SEMANTICS */




@@ -4780,11 +4775,12 @@ grokdeclarator (const struct c_declarato
           in this file, C99 6.7.4p6.  In GNU C89, a function declared
           'extern inline' is an external reference.  */
        else if (declspecs->inline_p && storage_class != csc_static)
-#if WANT_C99_INLINE_SEMANTICS
-         DECL_EXTERNAL (decl) = (storage_class == csc_extern) == !
flag_isoc99;
-#else
-         DECL_EXTERNAL (decl) = (storage_class == csc_extern);
-#endif
+         DECL_EXTERNAL (decl) = (storage_class == csc_extern) == !
flag_isoc99_inline;
        else
          DECL_EXTERNAL (decl) = !initialized;
 
--- ./c.opt.~1~ 2006-11-02 16:23:36.000000000 -0800
+++ ./c.opt     2006-11-03 20:16:38.000000000 -0800
@@ -690,6 +690,10 @@ Display statistics accumulated during co
 fstrict-prototype
 C++ ObjC++
 
+fc99-inline
+C ObjC Init(0) Var(flag_isoc99_inline)
+Enable C99 semantics for inline
+
 ftabstop=
 C ObjC C++ ObjC++ Joined RejectNegative UInteger
 -ftabstop=<number>     Distance between tab stops for column reporting


And then set flag_isoc99_inline also when setting flag_isoc99 where ever
that is.

The doc part is the same except for it is unrelated to
-std=c99/-std=gnu99.  The main reason why I would have it independent is
because people might want C99 semantics for inlining but not for some
preprocessing tokens (Hex floats changes preprocessing a little bit).

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]