[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    More multiple-include testcases
From:       Neil Booth <neil () daikokuya ! demon ! co ! uk>
Date:       2001-09-30 12:00:34
[Download RAW message or body]

If any part of

#if !defined (guard)

comes from a macro (including an empty macro), clearly the MI
optimization must be turned off.  We get this right, but there are no
tests so I've added the one below.

Neil.

	* mi6.c, mi6a.h, mi6b.h, mi6c.h, mi6d.h, mi6e.h: New test.

Index: mi6.c
===================================================================
RCS file: mi6.c
diff -N mi6.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6.c	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,44 @@
+/* Another test case for over-eager multiple include optimization,
+   where the leading "#if !defined" expression is obtained partially,
+   or wholly, from macros.  Neil Booth, 30 Sep 2001.  */
+
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Each include file should not be subject to MI optimisation, since
+   macro definitions can change.  Each header increments the variable
+   VAR if it is defined.
+
+   The first set of inclusions gets the headers into CPP's cache, but
+   does nothing since VAR is not defined.  The second set should each
+   increment VAR, since none of the initial set should have been
+   flagged as optimizable.  */
+
+#define EMPTY
+#define NOT !
+#define DEFINED defined (macro)
+#define IND ! defined (macro)
+
+#include "mi6a.h"
+#include "mi6b.h"
+#include "mi6c.h"
+#include "mi6d.h"
+#include "mi6e.h"
+
+#define VAR five
+
+int
+main(void)
+{
+  unsigned int five = 0;
+
+#include "mi6a.h"
+#include "mi6b.h"
+#include "mi6c.h"
+#include "mi6d.h"
+#include "mi6e.h"
+
+  if (five != 5)
+    abort ();
+  return 0;
+}
Index: mi6a.h
===================================================================
RCS file: mi6a.h
diff -N mi6a.h
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6a.h	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,5 @@
+#if IND
+ #ifdef VAR
+   VAR++;
+ #endif
+#endif
Index: mi6b.h
===================================================================
RCS file: mi6b.h
diff -N mi6b.h
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6b.h	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,5 @@
+#if NOT defined (macro)
+ #ifdef VAR
+   VAR++;
+ #endif
+#endif
Index: mi6c.h
===================================================================
RCS file: mi6c.h
diff -N mi6c.h
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6c.h	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,5 @@
+#if !DEFINED
+ #ifdef VAR
+   VAR++;
+ #endif
+#endif
Index: mi6d.h
===================================================================
RCS file: mi6d.h
diff -N mi6d.h
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6d.h	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,5 @@
+#if EMPTY !defined (macro)
+ #ifdef VAR
+   VAR++;
+ #endif
+#endif
Index: mi6e.h
===================================================================
RCS file: mi6e.h
diff -N mi6e.h
--- /dev/null	Tue May  5 13:32:27 1998
+++ mi6e.h	Sun Sep 30 04:53:51 2001
@@ -0,0 +1,5 @@
+#if !defined (macro) EMPTY
+ #ifdef VAR
+   VAR++;
+ #endif
+#endif

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic