gcc-10.2.0-cpp-__has_include.patch 1.52 KB
Newer Older
l_opal's avatar
l_opal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
From b7bb13d4a5fcb593dc745ca3b6180f8babb54893 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tiziano=20M=C3=BCller?= <tiziano.mueller@chem.uzh.ch>
Date: Mon, 27 Jul 2020 15:40:38 +0200
Subject: [PATCH] libcpp: fix __has_include handling with traditional-cpp

fixes #95889
---
 libcpp/init.c        | 3 +++
 libcpp/traditional.c | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libcpp/init.c b/libcpp/init.c
index 0aac5acd0a35..b0cf71192589 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -400,6 +400,9 @@ static const struct builtin_macro builtin_array[] =
   B("__LINE__",		 BT_SPECLINE,      true),
   B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true),
   B("__COUNTER__",	 BT_COUNTER,       true),
+  /* Make sure to update the list of built-in
+     function-like macros in traditional.c:
+     fun_like_macro() when adding more following */
   B("__has_attribute",	 BT_HAS_ATTRIBUTE, true),
   B("__has_cpp_attribute", BT_HAS_ATTRIBUTE, true),
   B("__has_builtin",	 BT_HAS_BUILTIN,   true),
diff --git a/libcpp/traditional.c b/libcpp/traditional.c
index 77adb3bf595f..b087072c9b4c 100644
--- a/libcpp/traditional.c
+++ b/libcpp/traditional.c
@@ -330,7 +330,9 @@ fun_like_macro (cpp_hashnode *node)
 {
   if (cpp_builtin_macro_p (node))
     return (node->value.builtin == BT_HAS_ATTRIBUTE
-	    || node->value.builtin == BT_HAS_BUILTIN);
+	    || node->value.builtin == BT_HAS_BUILTIN
+	    || node->value.builtin == BT_HAS_INCLUDE
+	    || node->value.builtin == BT_HAS_INCLUDE_NEXT);
   return node->value.macro->fun_like;
 }