public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99380] New: [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit
@ 2021-03-04  9:09 boris at kolpackov dot net
  2021-04-05 14:55 ` [Bug c++/99380] " cvs-commit at gcc dot gnu.org
  2021-04-05 14:56 ` nathan at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: boris at kolpackov dot net @ 2021-03-04  9:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99380

            Bug ID: 99380
           Summary: [modules] Unexpected MODULE-EXPORT request when
                    partially preprocessing header unit
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

A change between 11.0.0 20210217 and 11.0.1 20210304 causes an unexpected
MODULE-EXPORT request when partially preprocessing a header unit that imports
another header unit:

cat <<EOF >hello.hxx
#pragma once

#if 1
import <string_view>;
#else
#include <string_view>
#endif

namespace hello
{
  void
  say_hello (const std::string_view& name);
}
EOF

cat <<EOF >mapper
#!/usr/bin/env bash

function info () { echo "$*" 1>&2; }
function resp () { info "  < $*"; echo "$*"; }

while read l; do
  info "  > $l"

  case "$l" in
    HELLO*)
      resp "HELLO 1 test ;"
      ;;
    MODULE-REPO)
      resp "PATHNAME /"
      ;;
    MODULE-EXPORT*"string_view 1"|MODULE-IMPORT*string_view)
      resp "PATHNAME $(pwd)/string_view.gcm"
      ;;
    INCLUDE-TRANSLATE*)
      resp "BOOL FALSE"
      ;;
    MODULE-COMPILED*)
      resp "OK"
      ;;
    *)
      resp "ERROR 'unexpected request: $l'"
      ;;
  esac
done
EOF

chmod ugo+x mapper

g++ -std=c++2a -fmodules-ts -fmodule-mapper='|./mapper' -fmodule-header -x
c++-header .../include/c++/11.0.1/string_view
g++ -std=c++2a -fmodules-ts -fmodule-mapper='|./mapper' -E -fdirectives-only -o
hello.ii -fmodule-header -x c++-header hello.hxx

  > HELLO 1 GCC '' ;
  < HELLO 1 test ;
  > MODULE-REPO
  < PATHNAME /
  > MODULE-EXPORT ./hello.hxx ;
  < ERROR 'unexpected request: MODULE-EXPORT ./hello.hxx ;'
  > MODULE-IMPORT
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string_view
hello.hxx: error: unknown Compiled Module Interface: unexpected request:
MODULE-EXPORT ./hello.hxx ;

However, if I change hello.hxx to #include instead of import string_view, then
there is no MODULE-EXPORT:

g++ -std=c++2a -fmodules-ts -fmodule-mapper='|./mapper' -E -fdirectives-only -o
hello.ii -fmodule-header -x c++-header hello.hxx

  > HELLO 1 GCC '' ;
  < HELLO 1 test ;
  > MODULE-REPO
  < PATHNAME /
  > INCLUDE-TRANSLATE
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string_view
  < BOOL FALSE
  ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99380] [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit
  2021-03-04  9:09 [Bug c++/99380] New: [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit boris at kolpackov dot net
@ 2021-04-05 14:55 ` cvs-commit at gcc dot gnu.org
  2021-04-05 14:56 ` nathan at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-05 14:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99380

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:

https://gcc.gnu.org/g:dd6f588a7b8878d677af51ff4d1c1e3f9f6f40db

commit r11-7989-gdd6f588a7b8878d677af51ff4d1c1e3f9f6f40db
Author: Nathan Sidwell <nathan@acm.org>
Date:   Mon Apr 5 07:51:28 2021 -0700

    c++: Unneeded export query [PR 99380]

    This problem got introduced fixing a module numbering problem.  When
    preprocessing a header unit, we don't need to send an EXPORT query
    unless we're also determining dependencies, or the mapper asked us
    to.  Sadly the testsuite isn't set up to test this kind of subtlety.
    I manually did that with stdin/stdout.

            PR c++/99380
            gcc/cp/
            * module.cc (name_pending_imports): Drop 'atend' parm.  Don't
            query export when not needed.
            (preprocess_module, preprocessed_module): Adjust.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99380] [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit
  2021-03-04  9:09 [Bug c++/99380] New: [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit boris at kolpackov dot net
  2021-04-05 14:55 ` [Bug c++/99380] " cvs-commit at gcc dot gnu.org
@ 2021-04-05 14:56 ` nathan at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-04-05 14:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99380

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
* dd6f588a7b8 2021-04-05 | c++: Unneeded export query [PR 99380]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-05 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04  9:09 [Bug c++/99380] New: [modules] Unexpected MODULE-EXPORT request when partially preprocessing header unit boris at kolpackov dot net
2021-04-05 14:55 ` [Bug c++/99380] " cvs-commit at gcc dot gnu.org
2021-04-05 14:56 ` nathan at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).