From 15a0bdd32df89aa8d2e5ab49e07061f0708651e6 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 8 Apr 2021 13:41:30 +0200 Subject: make update_pch.sh aware of '#pragma once' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Headers are allowed to have one #if block that is not ignored, on the assumption that it is the include guard. This shouldn't be the case if the header uses #pragma once, obviously. Change-Id: Ib0aa0933ce224ca4e3ecf209593852da0f4ca5ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113799 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- bin/update_pch | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bin/update_pch') diff --git a/bin/update_pch b/bin/update_pch index 9b541d8a87a9..974d53ab9197 100755 --- a/bin/update_pch +++ b/bin/update_pch @@ -727,6 +727,12 @@ def process_source(root, module, filename, maxdepth=0): else: lastif = '#if' del allowed_ifs[ ifdepth ] + elif line.startswith('#pragma once'): + # maxdepth == 1 means we are parsing a header file + # and are allowed one #ifdef block (the include guard), + # but in the #pragma once case do not allow that + assert maxdepth == 1 + maxdepth = 0 elif line.startswith('#include'): if ifdepth - ifsallowed <= maxdepth: line = sanitize(line) -- cgit