Re: [PATCH][Preprocessor]patch to fix PR 90581
On Thu, May 30, 2019 at 10:46 PM David Malcolm 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. Not sure - this is for language limits and we do have existing like -ftemplate-backtrace-limit and -ftemplate-depth. > 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. > > 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
Re: [PATCH][Preprocessor]patch to fix PR 90581
> On May 30, 2019, at 3:46 PM, David Malcolm 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
Re: [PATCH][Preprocessor]patch to fix PR 90581
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. 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. 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
Re: [PATCH][Preprocessor]patch to fix PR 90581
> On May 30, 2019, at 3:38 PM, David Malcolm wrote: > > On Thu, 2019-05-30 at 15:17 -0500, Qing Zhao wrote: >>> On May 30, 2019, at 2:13 PM, Bernhard Reutner-Fischer >> gmail.com> wrote: >>> >>> On 30 May 2019 18:23:43 CEST, 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 >>> >>> Typo inl vs inc. >> >> Okay, will fix this. >> >>> >>> Why isn't this a param? >> >> do you mean to change “-fmax-include-depth=” to “-param max-include- >> depth=“? >> > > That sounds like a good idea to me. can -param be accepted by preprocessor? I didn’t see any -param in gcc/c-family/c.opt. where should I define a -param for preprocessor? thanks. Qing > >>> Wouldn't a param ease range checking not to overflow the uint max >>> and maybe automagically provide diagnostics for out of range input? > > (indeed) > >
Re: [PATCH][Preprocessor]patch to fix PR 90581
On Thu, 2019-05-30 at 15:17 -0500, Qing Zhao wrote: > > On May 30, 2019, at 2:13 PM, Bernhard Reutner-Fischer > gmail.com> wrote: > > > > On 30 May 2019 18:23:43 CEST, 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 > > > > Typo inl vs inc. > > Okay, will fix this. > > > > > Why isn't this a param? > > do you mean to change “-fmax-include-depth=” to “-param max-include- > depth=“? > That sounds like a good idea to me. > > Wouldn't a param ease range checking not to overflow the uint max > > and maybe automagically provide diagnostics for out of range input? (indeed)
Re: [PATCH][Preprocessor]patch to fix PR 90581
> On May 30, 2019, at 2:13 PM, Bernhard Reutner-Fischer > wrote: > > On 30 May 2019 18:23:43 CEST, 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 > > Typo inl vs inc. Okay, will fix this. > > Why isn't this a param? do you mean to change “-fmax-include-depth=” to “-param max-include-depth=“? > Wouldn't a param ease range checking not to overflow the uint max and maybe > automagically provide diagnostics for out of range input? > > In the docs you mix "number" and "depth”. will fix this. thanks for the feedback. Qing > > thanks, > >> 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. >> >> >> >> gcc/ChangeLog: >> >> 2019-05-30 qing zhao >> >> * doc/cppopts.texi: Add document for -fmax-include-depth. >> * doc/invoke.texi (Preprocessor Options): List -fmax-include-depth. >> >> libcpp/ChangeLog: >> >> 2019-05-30 qing zhao >> >> * directives.c (do_include_common): Replace CPP_STACK_MAX with >> CPP_OPTION (pfile, max_include_depth). >> * include/cpplib.h (struct cpp_options): Add new field >> max_include_depth. >> * init.c (cpp_create_reader): Initiate new field max_include_depth. >> * internal.h: Delete CPP_STACK_MAX. >> >> gcc/c-family/ChangeLog: >> >> 2019-05-30 qing zhao >> >> * c-opts.c (c_common_handle_option): Handle -fmax-include-depth. >> * c.opt: Add new option -fmax-include-depth. >> >> gcc/testsuite/ChangeLog: >> >> 2019-05-30 qing zhao >> >> * c-c++-common/cpp/fmax-include-depth-1a.h: New test. >> * c-c++-common/cpp/fmax-include-depth-1b.h: New test. >> * c-c++-common/cpp/fmax-include-depth.c: New test. >
Re: [PATCH][Preprocessor]patch to fix PR 90581
On 30 May 2019 18:23:43 CEST, 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 Typo inl vs inc. Why isn't this a param? Wouldn't a param ease range checking not to overflow the uint max and maybe automagically provide diagnostics for out of range input? In the docs you mix "number" and "depth". thanks, > 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. > > > >gcc/ChangeLog: > >2019-05-30 qing zhao > >* doc/cppopts.texi: Add document for -fmax-include-depth. >* doc/invoke.texi (Preprocessor Options): List -fmax-include-depth. > >libcpp/ChangeLog: > >2019-05-30 qing zhao > >* directives.c (do_include_common): Replace CPP_STACK_MAX with >CPP_OPTION (pfile, max_include_depth). >* include/cpplib.h (struct cpp_options): Add new field >max_include_depth. >* init.c (cpp_create_reader): Initiate new field max_include_depth. >* internal.h: Delete CPP_STACK_MAX. > >gcc/c-family/ChangeLog: > >2019-05-30 qing zhao > > * c-opts.c (c_common_handle_option): Handle -fmax-include-depth. >* c.opt: Add new option -fmax-include-depth. > >gcc/testsuite/ChangeLog: > >2019-05-30 qing zhao > >* c-c++-common/cpp/fmax-include-depth-1a.h: New test. >* c-c++-common/cpp/fmax-include-depth-1b.h: New test. >* c-c++-common/cpp/fmax-include-depth.c: New test.
[PATCH][Preprocessor]patch to fix PR 90581
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. gcc/ChangeLog: 2019-05-30 qing zhao * doc/cppopts.texi: Add document for -fmax-include-depth. * doc/invoke.texi (Preprocessor Options): List -fmax-include-depth. libcpp/ChangeLog: 2019-05-30 qing zhao * directives.c (do_include_common): Replace CPP_STACK_MAX with CPP_OPTION (pfile, max_include_depth). * include/cpplib.h (struct cpp_options): Add new field max_include_depth. * init.c (cpp_create_reader): Initiate new field max_include_depth. * internal.h: Delete CPP_STACK_MAX. gcc/c-family/ChangeLog: 2019-05-30 qing zhao * c-opts.c (c_common_handle_option): Handle -fmax-include-depth. * c.opt: Add new option -fmax-include-depth. gcc/testsuite/ChangeLog: 2019-05-30 qing zhao * c-c++-common/cpp/fmax-include-depth-1a.h: New test. * c-c++-common/cpp/fmax-include-depth-1b.h: New test. * c-c++-common/cpp/fmax-include-depth.c: New test. 0001-PR-preprocessor-90581.patch Description: Binary data