[llvm-bugs] [Bug 31660] New: inline namespace template ambiguities not well diagnosed

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 16 12:25:32 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31660

            Bug ID: 31660
           Summary: inline namespace template ambiguities not well
                    diagnosed
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hfinkel at anl.gov
                CC: eric at efcs.ca, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk
    Classification: Unclassified

Given this code:

$ cat /tmp/t6.cpp 
namespace ns {
inline namespace in {
template <class T>
class foo { };
}
}

namespace ns {
template <class T>
class foo { };
}

using namespace ns;
foo<int> x;

We produce only this error:

$ clang -stdlib=libc++ -fsyntax-only /tmp/t6.cpp -std=c++14
/tmp/t6.cpp:14:1: error: unknown type name 'foo'
foo<int> x;
^
/tmp/t6.cpp:14:4: error: expected unqualified-id
foo<int> x;
   ^
2 errors generated.

This is really confusing. The problem, I can only suppose, is that the lookup
is ambiguous, but we don't say that (and, thus, we fail to point out the
relevant candidates).

If foo were not a template, like this:

$ cat /tmp/t7.cpp 
namespace ns {
inline namespace in {
class foo { };
}
}

namespace ns {
class foo { };
}

using namespace ns;
foo x;

then we produce a very sensible error:

$ clang -stdlib=libc++ -fsyntax-only /tmp/t7.cpp -std=c++14
/tmp/t7.cpp:12:1: error: reference to 'foo' is ambiguous
foo x;
^
/tmp/t7.cpp:3:7: note: candidate found by name lookup is 'ns::in::foo'
class foo { };
      ^
/tmp/t7.cpp:8:7: note: candidate found by name lookup is 'ns::foo'
class foo { };
      ^
1 error generated.

Can we do better in the template case?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170116/c5f118cb/attachment.html>


More information about the llvm-bugs mailing list