changeset 482:4bf62ce997e7

Workaround for a bug in glibc where #include <regex.h> misuses restrict. tcc -E boils down to: extern int regexec ( const regex_t * __preg , const char * __string , size_t __nmatch , regmatch_t __pmatch [ restrict ] , int __eflags ) ; and "type name[restrict]" is not a valid variable declaration. Feed that to gcc, it'll barf in the same way. (glibc headers have specific #ifdef checks for various gcc versions and don't wind up outputting that for them, but for an unrecognized c99 compiler they output something invalid.)
author Rob Landley <rob@landley.net>
date Fri, 21 Sep 2007 16:21:19 -0500
parents 0f5c38ddf450
children a62ad123624a
files tcc.c tests/tcctest.c
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tcc.c	Fri Sep 21 02:43:28 2007 -0500
+++ b/tcc.c	Fri Sep 21 16:21:19 2007 -0500
@@ -6133,6 +6133,7 @@
     } else if (tok == '[') {
         /* array definition */
         next();
+        if (tok == TOK_RESTRICT1) next(); /* Work around bug in glibc regex.h */
         n = -1;
         if (tok != ']') {
             n = expr_const();
--- a/tests/tcctest.c	Fri Sep 21 02:43:28 2007 -0500
+++ b/tests/tcctest.c	Fri Sep 21 16:21:19 2007 -0500
@@ -2203,3 +2203,7 @@
 #  include <windows.h>
 #  include <gl\glaux.h>
 #endif
+
+// Check workaround for a bug in glibc defining something like
+// "int blah[restrict];" which isn't legal syntax.
+#include <regex.h>