+2019-07-02 qing zhao <qing.zhao@oracle.com>
+
+ PR preprocessor/90581
+ * doc/cppopts.texi: Add document for -fmax-include-depth.
+ * doc/invoke.texi (Preprocessor Options): List -fmax-include-depth.
+
2019-07-02 Uroš Bizjak <ubizjak@gmail.com>
* config/i386/mmx.md (mmx_pack<s_trunsuffix>swb):
+2019-07-02 qing zhao <qing.zhao@oracle.com>
+
+ PR preprocessor/90581
+ * c-opts.c (c_common_handle_option): Handle -fmax-include-depth.
+ * c.opt: Add new option -fmax-include-depth.
+
2019-06-26 Jason Merrill <jason@redhat.com>
PR c++/55442 - memory-hog with highly recursive constexpr.
cpp_opts->extended_identifiers = value;
break;
+ case OPT_fmax_include_depth_:
+ cpp_opts->max_include_depth = value;
+ break;
+
case OPT_foperator_names:
cpp_opts->operator_names = value;
break;
C ObjC C++ ObjC++ Var(flag_lax_vector_conversions)
Allow implicit conversions between vectors with differing numbers of subparts and/or differing element types.
+fmax-include-depth=
+C ObjC C++ ObjC++ Joined RejectNegative UInteger
+fmax-include-depth=<number> Set the maximum depth of the nested #include.
+
fms-extensions
C ObjC C++ ObjC++ Var(flag_ms_extensions)
Don't warn about uses of Microsoft extensions.
@opindex fno-canonical-system-headers
When preprocessing, do not shorten system header paths with canonicalization.
+@item -fmax-include-depth=@var{depth}
+@opindex fmax-include-depth
+Set the maximum depth of the nested #include. The default is 200.
+
@item -ftabstop=@var{width}
@opindex ftabstop
Set the distance between tab stops. This helps the preprocessor report
-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
-fexec-charset=@var{charset} -fextended-identifiers @gol
-finput-charset=@var{charset} -fmacro-prefix-map=@var{old}=@var{new} @gol
+-fmax-include-depth=@var{depth} @gol
-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
-fwide-exec-charset=@var{charset} -fworking-directory @gol
+2019-07-02 qing zhao <qing.zhao@oracle.com>
+
+ PR preprocessor/90581
+ * 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.
+
2019-07-02 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/alias-access-path-7.c: New testcase.
--- /dev/null
+#include "fmax-include-depth-1a.h"
--- /dev/null
+/* { dg-do preprocess} */
+/* { dg-options "-fmax-include-depth=1" } */
+
+#include "fmax-include-depth-1b.h" /* { dg-error ".include nested depth 1 exceeds maximum of 1 .use -fmax-include-depth=DEPTH to increase the maximum." } */
+2019-07-02 qing zhao <qing.zhao@oracle.com>
+
+ PR preprocessor/90581
+ * 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.
+
2019-06-26 Nathan Sidwell <nathan@acm.org>
PR preprocessor/90927
}
/* Prevent #include recursion. */
- if (pfile->line_table->depth >= CPP_STACK_MAX)
- cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply");
+ if (pfile->line_table->depth >= CPP_OPTION (pfile, max_include_depth))
+ cpp_error (pfile,
+ CPP_DL_ERROR,
+ "#include nested depth %u exceeds maximum of %u"
+ " (use -fmax-include-depth=DEPTH to increase the maximum)",
+ pfile->line_table->depth,
+ CPP_OPTION (pfile, max_include_depth));
else
{
/* Get out of macro context, if we are. */
/* True enables canonicalization of system header file paths. */
bool canonical_system_headers;
+
+ /* The maximum depth of the nested #include. */
+ unsigned int max_include_depth;
};
/* Diagnostic levels. To get a diagnostic without associating a
CPP_OPTION (pfile, warn_multichar) = 1;
CPP_OPTION (pfile, discard_comments) = 1;
CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
+ CPP_OPTION (pfile, max_include_depth) = 200;
CPP_OPTION (pfile, tabstop) = 8;
CPP_OPTION (pfile, operator_names) = 1;
CPP_OPTION (pfile, warn_trigraphs) = 2;
linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \
} while (0)
-/* Maximum nesting of cpp_buffers. We use a static limit, partly for
- efficiency, and partly to limit runaway recursion. */
-#define CPP_STACK_MAX 200
-
/* Host alignment handling. */
struct dummy
{