[llvm-bugs] [Bug 48558] New: using-directive injects names into wrong namespace scope
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Dec 19 07:27:57 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48558
Bug ID: 48558
Summary: using-directive injects names into wrong namespace
scope
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: arthur.j.odwyer at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
// https://godbolt.org/z/8bEMfW
struct Cat {};
struct Lion : Cat {};
namespace Outer {
namespace Inner {
namespace N1 {
int foo(Cat);
}
namespace N2 {
int test();
}
}
int foo(Lion);
int Inner::N2::test() {
using namespace Inner::N1;
return (foo)(Lion());
}
}
When Clang sees the using-directive, it seems to insert a declaration of
Outer::Inner::N1::foo(Cat) into the lowest-common-ancestor namespace of Outer
(where the definition of `Inner::N2::test()` appears) and Outer::Inner::N1.
However, it SHOULD insert the declaration into the lowest-common-ancestor
namespace of Outer::Inner::N2 (where the original declaration of `test()`
appeared) and Outer::Inner::N1.
The parens in `(foo)(Lion())` are just there to turn off ADL to simplify the
example; they're not relevant to the bug.
--
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/20201219/d42a50b1/attachment.html>
More information about the llvm-bugs
mailing list