[pushed:,v2] text-art: remove explicit #include of C++ standard library headers
Checks
Commit Message
On Fri, 2023-06-23 at 16:35 +0100, Alex Coplan wrote:
> Thanks for the fix! I can confirm this fixes bootstrap on
> x86_64-apple-darwin for me.
Thanks Alex
Unfortunately the patch I posted broke the build of the plugin in
the testsuite, so I had to tweak things slightly.
Here's v2 of the patch, which fixes the plugin, and also adds a check to
text-art/types.h to ensure that INCLUDE_VECTOR was defined.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
I've pushed it to trunk as r14-2059-gb2e075a594e93a.
Hopefully this version also fixes the build for you; let me know if
this is still causing problems.
Sorry again for the breakage
Dave
gcc/analyzer/ChangeLog:
* access-diagram.cc: Add #define INCLUDE_VECTOR.
* bounds-checking.cc: Likewise.
gcc/ChangeLog:
* diagnostic-format-sarif.cc: Add #define INCLUDE_VECTOR.
* diagnostic.cc: Likewise.
* text-art/box-drawing.cc: Likewise.
* text-art/canvas.cc: Likewise.
* text-art/ruler.cc: Likewise.
* text-art/selftests.cc: Likewise.
* text-art/selftests.h (text_art::canvas): New forward decl.
* text-art/style.cc: Add #define INCLUDE_VECTOR.
* text-art/styled-string.cc: Likewise.
* text-art/table.cc: Likewise.
* text-art/table.h: Remove #include <vector>.
* text-art/theme.cc: Add #define INCLUDE_VECTOR.
* text-art/types.h: Check that INCLUDE_VECTOR is defined.
Remove #include of <vector> and <string>.
* text-art/widget.cc: Add #define INCLUDE_VECTOR.
* text-art/widget.h: Remove #include <vector>.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_text_art.c: Add
#define INCLUDE_VECTOR.
---
gcc/analyzer/access-diagram.cc | 1 +
gcc/analyzer/bounds-checking.cc | 1 +
gcc/diagnostic-format-sarif.cc | 1 +
gcc/diagnostic.cc | 1 +
.../gcc.dg/plugin/diagnostic_plugin_test_text_art.c | 1 +
gcc/text-art/box-drawing.cc | 1 +
gcc/text-art/canvas.cc | 1 +
gcc/text-art/ruler.cc | 1 +
gcc/text-art/selftests.cc | 1 +
gcc/text-art/selftests.h | 4 +++-
gcc/text-art/style.cc | 1 +
gcc/text-art/styled-string.cc | 1 +
gcc/text-art/table.cc | 1 +
gcc/text-art/table.h | 1 -
gcc/text-art/theme.cc | 1 +
gcc/text-art/types.h | 10 ++++++++--
gcc/text-art/widget.cc | 1 +
gcc/text-art/widget.h | 1 -
18 files changed, 25 insertions(+), 5 deletions(-)
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#define INCLUDE_MEMORY
#define INCLUDE_MAP
#define INCLUDE_SET
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "make-unique.h"
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "diagnostic.h"
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
message module. */
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "version.h"
@@ -2,6 +2,7 @@
/* This plugin exercises the text_art code. */
+#define INCLUDE_VECTOR
#include "gcc-plugin.h"
#include "config.h"
#include "system.h"
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "text-art/box-drawing.h"
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "pretty-print.h"
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_ALGORITHM
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "pretty-print.h"
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "selftest.h"
@@ -22,7 +22,9 @@ along with GCC; see the file COPYING3. If not see
#if CHECKING_P
-#include "text-art/types.h"
+namespace text_art {
+ class canvas;
+} // namespace text_art
namespace selftest {
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_ALGORITHM
#define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "make-unique.h"
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "make-unique.h"
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "make-unique.h"
@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
#include "text-art/canvas.h"
#include "text-art/theme.h"
-#include <vector>
namespace text_art {
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "pretty-print.h"
@@ -21,10 +21,16 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_TEXT_ART_TYPES_H
#define GCC_TEXT_ART_TYPES_H
+/* This header uses std::vector, but <vector> can't be directly
+ included due to issues with macros. Hence it must be included from
+ system.h by defining INCLUDE_MEMORY in any source file using it. */
+
+#ifndef INCLUDE_VECTOR
+# error "You must define INCLUDE_VECTOR before including system.h to use text-art/types.h"
+#endif
+
#include "cpplib.h"
#include "pretty-print.h"
-#include <vector>
-#include <string>
namespace text_art {
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
#include "system.h"
#include "coretypes.h"
#include "pretty-print.h"
@@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_TEXT_ART_WIDGET_H
#define GCC_TEXT_ART_WIDGET_H
-#include <vector>
#include "text-art/canvas.h"
#include "text-art/table.h"