This is the mail archive of the 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: gcc-3.3 fixincludes patch. (Was: [Autogen-bugs] autogen-5.5.5)

Peter Breitenlohner wrote:
> .... I wanted to apply some modifications to gcc-3.3's fixinclude in
> order to avoid some annoying fixes of files that are in fact already fixed.
> The most prominent example is the replacement of
>         #ifndef __cplusplus
>         typedef whatever wchar_t;
>         #endif
> by
>         #ifndef __cplusplus
>         #ifndef __cplusplus
>         typedef whatever wchar_t;
>         #endif
>         #endif
> I was about to submit these changes as a gcc-patch, but am not quite sure
> under what component category.
> Anyway, since you are the maintainer of fixincludes, you should as well get
> a copy, so I have attached the patch.
> Please tell me if I should still submit it to gcc-bugzilla.

It won't help much because I don't get notified about gcc-bugzilla stuff.
At any rate, to your patch:

> 	I allways found it annoying that the avoid_wchar_t_type test of
> 	fixincludes fixes files that are already `fixed', i.e., where
> 	the wchar_t typedef is already protected by `#ifndef __cplusplus'.
> 	I think that should be considered as a misfeature (aka. bug).

One tries to reduce useless fixes.

> 	I know the new version of this test isn't entirely perfect, but I
> 	think it safe to assume that either none or all wchar_t typedefs in
> 	a header file are protected.

I'd go further and say that if a header is C++ aware, then the wchar_t's
should be protected.  Does anyone know of a platform that has a header
that claims to be C++ aware and yet has an unprotected typedef of wchar_t?

> 	Same for math_huge_val_ifndef and stdio_va_list, these should really
> 	be safe.

Re: HUGE_VAL: ``bypass   = "ifndef HUGE_VAL";'' should suffice.

You didn't explain the third diff:  DUMMY_VA_LIST
I guess you have a situation where you wound up with a double dummy list?

diff -ur -N gcc-3.3.orig/gcc/fixinc/inclhack.def gcc-3.3/gcc/fixinc/inclhack.def
--- gcc-3.3.orig/gcc/fixinc/inclhack.def	2003-05-07 04:10:48.000000000 +0200
+++ gcc-3.3/gcc/fixinc/inclhack.def	2003-06-12 14:40:21.000000000 +0200
@@ -769,11 +769,15 @@
     hackname = avoid_wchar_t_type;
     select    = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
+    bypass    = "^#ifndef __cplusplus\n[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
     c_fix     = format;
     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
     test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
+    test_text = "#ifndef __cplusplus\n"
+                "typedef unsigned short\twchar_t \t; /* wchar_t\n type */\n"
+                "#endif";
@@ -1930,13 +1934,17 @@
     hackname = math_huge_val_ifndef;
     files    = math.h;
     files    = math/math.h;
-    select   = "define[ \t]+HUGE_VAL";
+    select   = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
+    bypass   = "^#ifndef HUGE_VAL\n"
+               "[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
     c_fix     = format;
     c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
-    c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
     test_text = "# define\tHUGE_VAL 3.4e+40";
+    test_text = "#ifndef HUGE_VAL\n"
+                "# define\tHUGE_VAL 3.4e+40\n"
+                "#endif";
@@ -2420,6 +2428,7 @@
            "@typedef \\1 __not_va_list__;@\n"
 	  "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
-          "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
-          "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
+          "s@\\(GNUC|DUMMY|_NEED__\\)_VA_LIST@\\1_Va_LIST@\n"

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