> On May 30, 2019, at 3:46 PM, David Malcolm <dmalc...@redhat.com> wrote: > > On Thu, 2019-05-30 at 11:23 -0500, Qing Zhao wrote: >> Hi, >> >> PR 90581 (provide an option to adjust the maximum depth of nested >> #include) >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90581 >> >> is to add a new cpp option -fmax-inlcude-depth to set the maximum >> depth of nested #include. >> >> '-fmax-include-depth=DEPTH' >> Set the maximum depth of the nested include. The default value >> is >> 200. >> >> Please check the attached patch. >> I have done bootstrap and regression test on X86, no any issue. >> >> thanks a lot. >> >> Qing. >> > Thanks for working on this. It's looking promising, but I agree that a > param would be better than an option.
I just checked both gcc source code and gcc documentation. looks like that —param name=value is an option for “Options that Control Optimization”. Since this new option is for preprocessor, I think that it might not be fit in? let me know if I miss anything here. > > One idea that occurred to me looking at the patch... > >> index 3ee8bc4..480c282 100644 >> --- a/libcpp/directives.c >> +++ b/libcpp/directives.c >> @@ -831,7 +831,7 @@ do_include_common (cpp_reader *pfile, enum include_type >> type) >> } >> >> /* Prevent #include recursion. */ >> - if (pfile->line_table->depth >= CPP_STACK_MAX) >> + if (pfile->line_table->depth >= CPP_OPTION (pfile, max_include_depth)) >> cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply"); > > ...a nice usability tweak here would be to give a hint about the new > param, to give the user an idea on how to increase the limit. Yes, I agree. will fix this. Thanks. Qing > > Maybe something like: > > cpp_error (pfile, CPP_DL_ERROR, > "%<#include%> nested too deeply (depth %i);" > " use %<--param max-include-depth=LIMIT%> to support deeper nesting", > pfile->line_table->depth); > > (though probably that would be better as a followup "note") > > Dave