[1/2] libcpp: fix __has_include handling with traditional-cpp

Message ID 20200728072830.6615-2-tiziano.mueller@chem.uzh.ch
State New
Headers show
Series
  • cpp: fix __has_include in traditional mode
Related show

Commit Message

Tiziano Müller July 28, 2020, 7:28 a.m.
fixes #95889
---
 libcpp/init.c        | 3 +++
 libcpp/traditional.c | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.26.1

Patch

diff --git a/libcpp/init.c b/libcpp/init.c
index 0aac5acd0a3..b0cf7119258 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 77adb3bf595..b087072c9b4 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;
 }