[cfe-dev] Elaborated type refers to a type alias

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 22 08:22:07 PDT 2016

On 21 Sep 2016 4:38 pm, "Petr Hosek via cfe-dev" <cfe-dev at lists.llvm.org>

We ran into an error when trying to build one of our existing projects with
Clang. The minimal example looks as follows:

template <typename S> struct Foo {
  struct Bar {
    using Baz = Foo<S>;
  template <typename T> struct Qux {
    friend struct Bar::Baz;

Foo<int>::Qux<int> qux;

When trying build this example with Clang, it produces the following error:
test.cc:6:24: error: elaborated type refers to a type alias. However, GCC
handles this example just fine.

IIUC in this case Clang follows the C++ standard which specifies
that elaborated type specifier cannot refer to a type alias. However, I
would like to ask if anyone can explain the underlying motivation? In this
case it seems to be pretty clear what Baz refers to. Is there any reason
why Clang cannot allow it (except for strictly adhering to standards)?

You can fix your code by deleting the 'struct' keyword from the friend
declaration. Vendor extensions have a history of doing harm to the C++
language, and it seems hard to justify one here given the correct code is
simpler than the incorrect code.

cfe-dev mailing list
cfe-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160922/0e547ee4/attachment.html>

More information about the cfe-dev mailing list