<html>
    <head>
      <base href="https://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 - Class with same name as module causes compilation error due to incorrect resolution to forward declaration in another module"
   href="https://bugs.llvm.org/show_bug.cgi?id=52138">52138</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Class with same name as module causes compilation error due to incorrect resolution to forward declaration in another module
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>rhow@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25349" name="attach_25349" title="test case">attachment 25349</a> <a href="attachment.cgi?id=25349&action=edit" title="test case">[details]</a></span>
test case

During a migration to using submodules for some of our libraries we have come
across an edge case where a type with the same name as its containing module is
not found in its imported module, but instead incorrectly located in an
unimported submodule that contains a forward declaration to that type.

I have attached a test case that illustrates the issue. Running the `build.sh`
script results in:

```
test.m:7:21: error: definition of 'c' must be imported from module 'b.b2'
before it is required
    return a.cthing.d;
                    ^
./b2.h:2:8: note: definition here is not reachable
@class c;
       ^
1 error generated.
```

Where test.m imports c.h that defines c:

```
#import "a.h"
#import "c.h"

int test(AClass *a);

int test(AClass *a) {
    return a.cthing.d;
}
```

Changing the order of imports, the name of the module or the name of the class
will compile correctly.</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>