C++ Joined RejectNegative MissingArgError(missing header name)
Note a #include translation of a specific header.
+flang-info-module-read
+C++ Var(note_module_read_yes)
+Note Compiled Module Interface pathnames.
+
+flang-info-module-read=
+C++ Joined RejectNegative MissingArgError(missing module name)
+Note Compiled Module Interface pathname of a specific module or header-unit.
+
fmax-include-depth=
C ObjC C++ ObjC++ Joined RejectNegative UInteger
fmax-include-depth=<number> Set the maximum depth of the nested #include.
/* Include files to note translation for. */
static vec<const char *, va_heap, vl_embed> *note_includes;
+/* Modules to note CMI pathames. */
+static vec<const char *, va_heap, vl_embed> *note_cmis;
+
/* Traits to hash an arbitrary pointer. Entries are not deletable,
and removal is a noop (removal needed upon destruction). */
template <typename T>
do it again */
bool call_init_p : 1; /* This module's global initializer needs
calling. */
+ bool inform_read_p : 1; /* Inform of a read. */
/* Record extensions emitted or permitted. */
unsigned extensions : SE_BITS;
- /* 12 bits used, 4 bits remain */
+ /* 13 bits used, 3 bits remain */
public:
module_state (tree name, module_state *, bool);
partition_p = partition;
+ inform_read_p = false;
+
extensions = 0;
if (name && TREE_CODE (name) == STRING_CST)
{
{
const char *file = maybe_add_cmi_prefix (filename);
dump () && dump ("CMI is %s", file);
+ if (note_module_read_yes || inform_read_p)
+ inform (loc, "reading CMI %qs", file);
fd = open (file, O_RDONLY | O_CLOEXEC | O_BINARY);
e = errno;
}
headers = BITMAP_GGC_ALLOC ();
if (note_includes)
+ /* Canonicalize header names. */
for (unsigned ix = 0; ix != note_includes->length (); ix++)
{
const char *hdr = (*note_includes)[ix];
(*note_includes)[ix] = path;
}
+ if (note_cmis)
+ /* Canonicalize & mark module names. */
+ for (unsigned ix = 0; ix != note_cmis->length (); ix++)
+ {
+ const char *name = (*note_cmis)[ix];
+ size_t len = strlen (name);
+
+ bool is_system = name[0] == '<';
+ bool is_user = name[0] == '"';
+ bool is_pathname = false;
+ if (!(is_system || is_user))
+ for (unsigned ix = len; !is_pathname && ix--;)
+ is_pathname = IS_DIR_SEPARATOR (name[ix]);
+ if (is_system || is_user || is_pathname)
+ {
+ if (len <= (is_pathname ? 0 : 2)
+ || (!is_pathname && name[len-1] != (is_system ? '>' : '"')))
+ {
+ error ("invalid header name %qs", name);
+ continue;
+ }
+ else
+ name = canonicalize_header_name (is_pathname ? nullptr : reader,
+ 0, is_pathname, name, len);
+ }
+ if (auto module = get_module (name))
+ module->inform_read_p = 1;
+ else
+ error ("invalid module name %qs", name);
+ }
+
dump.push (NULL);
/* Determine lazy handle bound. */
vec_safe_push (note_includes, str);
return true;
+ case OPT_flang_info_module_read_:
+ vec_safe_push (note_cmis, str);
+ return true;
+
default:
return false;
}
-fvisibility-inlines-hidden @gol
-fvisibility-ms-compat @gol
-fext-numeric-literals @gol
--flang-info-include-translate@r{[}=@var{name}@r{]} @gol
+-flang-info-include-translate@r{[}=@var{header}@r{]} @gol
-flang-info-include-translate-not @gol
+-flang-info-module-read@r{[}=@var{module}@r{]} @gol
-stdlib=@var{libstdc++,libc++} @gol
-Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
-Wno-class-conversion -Wclass-memaccess @gol
@itemx -flang-info-include-translate=@var{header}
@opindex flang-info-include-translate
@opindex flang-info-include-translate-not
-Diagnose include translation events. The first will note accepted
+Inform of include translation events. The first will note accepted
include translations, the second will note declined include
translations. The @var{header} form will inform of include
translations relating to that specific header. If @var{header} is of
the form @code{"user"} or @code{<system>} it will be resolved to a
specific user or system header using the include path.
+@item -flang-info-module-read
+@itemx -flang-info-module-read=@var{module}
+@opindex flang-info-module-read
+Inform of Compiled Module Interface pathnames. The first will note
+all read CMI pathnames. The @var{module} form will not reading a
+specific module's CMI. @var{module} may be a named module or a
+header-unit (the latter indicated by either being a pathname containing
+directory separators or enclosed in @code{<>} or @code{""}).
+
@item -stdlib=@var{libstdc++,libc++}
@opindex stdlib
When G++ is configured to support this option, it allows specification of
header files with that particular trailing pathname are noted. You
may repeat this form to cover several different header files. This
option may be helpful in determining whether include translation is
-happening---if it is working correctly, it'll behave as if it wasn't
+happening---if it is working correctly, it behaves as if it isn't
there at all.
+The @option{-flang-info-module-read} option can be used to determine
+where the compiler is reading a CMI from. Without the option, the
+compiler is silent when such a read is successful. This option has an
+optional argument, which will restrict the notification to just the
+set of named modules or header units specified.
+
The @option{-Winvalid-imported-macros} option causes all imported macros
to be resolved at the end of compilation. Without this, imported
macros are only resolved when expanded or (re)defined. This option
--- /dev/null
+// PR c++/99166, diagnostic
+// { dg-additional-options {-x c++-system-header iostream -fmodules-ts} }
+
+// { dg-prune-output {linker input file unused} }
+
+NO DO NOT COMPILE
--- /dev/null
+// { dg-additional-options {-fmodules-ts -flang-info-module-read=<iostream>} }
+export module Foo;
+import <iostream>;
+
+export void frob ();
+
+// { dg-regexp {In module imported at [^\n]*pr99166_b.C:[0-9:]*\n[^\b]*iostream: note: reading CMI 'gcm.cache/[^[\n]*iostream.gcm'\n} }
--- /dev/null
+// { dg-additional-options {-fmodules-ts -flang-info-module-read=Foo} }
+module Foo;
+
+// { dg-regexp {In module imported at [^\n]*pr99166_c.C:[0-9:]*\n[^\b]*Foo: note: reading CMI 'gcm.cache/Foo.gcm'\n} }
--- /dev/null
+// { dg-additional-options {-fmodules-ts -flang-info-module-read} }
+import Foo;
+
+// { dg-regexp {In module imported at [^\n]*pr99166_d.C:[0-9:]*\n[^\b]*Foo: note: reading CMI 'gcm.cache/Foo.gcm'\n} }
+
+// { dg-regexp {In module imported at [^\n]*pr99166_b.C:[0-9:]*,\nof module Foo, imported at [^\n]*pr99166_d.C:[0-9:]:\n[^\b]*iostream: note: reading CMI 'gcm.cache/[^[\n]*iostream.gcm'\n} }