aboutsummaryrefslogtreecommitdiff
path: root/libcpp/init.cc
diff options
context:
space:
mode:
authorLongjun Luo <luolongjuna@gmail.com>2023-04-30 12:28:06 -0600
committerJeff Law <jlaw@ventanamicro>2023-04-30 12:28:06 -0600
commite7ce7c4905fd254760b1cd187752a03bc0c148ba (patch)
treecb515cfd3af5bd61643d4680781bcd6d25948c3e /libcpp/init.cc
parent2744dbb9ecf104a113da3a0f39115da4653bb676 (diff)
downloadgcc-e7ce7c4905fd254760b1cd187752a03bc0c148ba.zip
gcc-e7ce7c4905fd254760b1cd187752a03bc0c148ba.tar.gz
gcc-e7ce7c4905fd254760b1cd187752a03bc0c148ba.tar.bz2
[PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__
From 0821df518b264e754d698d399f98be1a62945e32 Mon Sep 17 00:00:00 2001 From: Longjun Luo <luolongjuna@gmail.com> Date: Thu, 12 Jan 2023 23:59:54 +0800 Subject: [PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__ As implied in gcc.gnu.org/legacy-ml/gcc-patches/2008-09/msg00076.html, gcc provides -Wno-builtin-macro-redefined to suppress warning when redefining builtin macro. However, at that time, there was no scenario for __LINE__ macro. But, when we try to build a live-patch, we compare sections by using -ffunction-sections. Some same functions are considered changed because of __LINE__ macro. At present, to detect such a changed caused by __LINE__ macro, we have to analyse code and maintain a function list. For example, in kpatch, check this commit github.com/dynup/kpatch/commit/0e1b95edeafa36edb7bcf11da6d1c00f76d7e03d. So, in this scenario, when we try to compared sections, it would be better to support suppress builtin macro redefined warnings for __LINE__ macro. libcpp: * init.cc (builtin_array): Do not always warn for a redefinition of __LINE__. gcc/testsuite * gcc.dg/builtin-redefine.c: Test for redefintion warnings for __LINE__. * gcc.dg/builtin-redefine-1.c: New test.
Diffstat (limited to 'libcpp/init.cc')
-rw-r--r--libcpp/init.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcpp/init.cc b/libcpp/init.cc
index c508f06..bdeccff 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -421,7 +421,7 @@ static const struct builtin_macro builtin_array[] =
B("__FILE__", BT_FILE, false),
B("__FILE_NAME__", BT_FILE_NAME, false),
B("__BASE_FILE__", BT_BASE_FILE, false),
- B("__LINE__", BT_SPECLINE, true),
+ B("__LINE__", BT_SPECLINE, false),
B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true),
B("__COUNTER__", BT_COUNTER, true),
/* Make sure to update the list of built-in