<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Improve diagnostic for hidden decls coming from non-modular headers"
   href="http://bugs.llvm.org/show_bug.cgi?id=32670">32670</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve diagnostic for hidden decls coming from non-modular headers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Modules
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>bruno.cardoso@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18290" name="attach_18290" title="testcase">attachment 18290</a> <a href="attachment.cgi?id=18290&action=edit" title="testcase">[details]</a></span>
testcase

The following code snippet leads to a very confusing error (also attached for
easy reproduction):

MessageTypes.h:

#ifndef ROOT_MessageTypes
#define ROOT_MessageTypes

enum EMessageTypes {
   kROOTD_OPEN           = 2004,         //filename follows + mode
};

#endif

module.modulemap:

module "libNet.so" {
  requires cplusplus
  module "TMessage.h" { header "TMessage.h" export * }
  module "TNetFile.h" { header "TNetFile.h" export * }
  export *
}

Output:

TNetFile.cxx:1:10: remark: building module 'libNet.so' as
'/home/teemperor/Downloads/merge_enum/pcms/3MNDY7KURXTXS/libNet.so-141H35WZHCMDE.pcm'
[-Rmodule-build]
#include "TNetFile.h"
         ^
TNetFile.cxx:1:10: remark: finished building module 'libNet.so'
[-Rmodule-build]
TNetFile.cxx:2:10: error: declaration of 'kROOTD_OPEN' must be imported from
module 'libNet.so.TMessage.h' before it is required
auto v = kROOTD_OPEN;
         ^
In module 'libNet.so' imported from TNetFile.cxx:1:
./MessageTypes.h:5:4: note: previous declaration is here
   kROOTD_OPEN           = 2004,         //filename follows + mode
   ^
1 error generated.

test.sh:

#!/bin/bash

CLANG="/opt/clang/inst/bin/clang"

rm -rf ./pcms/
# Normal clang invocation
#"$CLANG" -cc1 -triple x86_64-apple-macosx10.11.0 -fsyntax-only -I . -std=c++11
-x c++ TNetFile.cxx -nostdsysteminc
# Modules clang invocation
"$CLANG" -cc1 -triple x86_64-apple-macosx10.11.0 -fsyntax-only -I . -std=c++11 
-fmodules  -fimplicit-module-maps -fmodules-cache-path=./pcms/
-fcolor-diagnostics -fdiagnostics-show-option
-fdiagnostics-show-note-include-stack -x c++ TNetFile.cxx -nostdsysteminc
-Rmodule-build

TMessage.h:

#ifndef ROOT_TMessage
#define ROOT_TMessage
#include "MessageTypes.h"
#endif

TNetFile.cxx:

#include "TNetFile.h"
auto v = kROOTD_OPEN;

TNetFile.h:

#ifndef ROOT_TNetFile
#define ROOT_TNetFile
#include "MessageTypes.h"
#endif</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>