From 6be3c0e13aaad3ef209dedcddb32a41a7f844f40 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 24 Aug 2018 02:58:21 +0000 Subject: [PATCH] Fix PCH conditional nesting --- SConstruct | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/SConstruct b/SConstruct index bcf3e0a0e..0e8d520f1 100644 --- a/SConstruct +++ b/SConstruct @@ -3015,13 +3015,14 @@ class PCHManager(object): # Ignore generated header here. PCH generation # will insert it in the right order. continue - if name == b'"valptridx.tcc"': - # Exclude tcc file from PCH. It is not meant to - # be included in every file. Starting in gcc-7, - # static functions defined in valptridx.tcc - # generate -Wunused-function warnings if the - # including file does not instantiate any - # templates that use the static function. + if not name.endswith(b'.h"'): + # Exclude non-header files from PCH. + # + # Starting in gcc-7, static functions defined in + # valptridx.tcc generate -Wunused-function + # warnings if the including file does not + # instantiate any templates that use the static + # function. continue if header_search_path is None: header_search_path = [ @@ -3049,10 +3050,17 @@ class PCHManager(object): name = env.File(name.decode()) candidates[name].add(tuple(guard)) elif directive == b'endif': - # guard should always be True here, but test to avoid - # ugly errors if scanning an ill-formed source file. - if guard: - guard.pop() + while guard: + g = guard.pop() + if g == b'#else': + # guard should always be True here, but test to + # avoid ugly errors if scanning an ill-formed + # source file. + if guard: + guard.pop() + break + if not g.startswith(b'#elif '): + break elif directive == b'else': # #else is handled separately because it has no # arguments