From 70a7bc396797cc0808939e092b2d6f9f19eb8ab1 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Mon, 5 Feb 2018 12:05:04 +0000 Subject: [PATCH] transform_mjit_header.rb: remove predefined macros semi-automatically. This is basically for icc's __DATE__, __TIME__, and many other families. It causes an error by predefined macro redefinition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/transform_mjit_header.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tool/transform_mjit_header.rb b/tool/transform_mjit_header.rb index dc5f9e11c1..23f64a8576 100644 --- a/tool/transform_mjit_header.rb +++ b/tool/transform_mjit_header.rb @@ -93,10 +93,9 @@ module MJITHeader code.gsub!(/^#define #{Regexp.union(RECURSIVE_MACROS)} .*$/, '') end - # -dD outputs those macros, and it produces redefinition warnings - def self.remove_default_macros!(code) - code.gsub!(/^#define __STDC_.+$/, '') - code.gsub!(/^#define assert\([^\)]+\) .+$/, '') + # -dD outputs those macros, and it produces redefinition warnings or errors + def self.remove_predefined_macros!(code) + code.sub!(/\A(#define [^\n]+|\n)*(#define MJIT_HEADER 1\n)/, '\2') end # This makes easier to process code @@ -132,7 +131,7 @@ end if MJITHeader.windows? MJITHeader.remove_harmful_macros!(code) end -MJITHeader.remove_default_macros!(code) +MJITHeader.remove_predefined_macros!(code) # Check initial file correctness MJITHeader.check_code!(code, cc, cflags, 'initial')