Issue 141020.1: C++11 inline namespaces
Section Namespace Entries, pg
Issue: ?
Description: C++11 inline namespaces
Type: Enhancement
Submitter: Adrian Prantl <aprantl@apple.com>
Championed: Adrian Prantl <aprantl@apple.com>
Background for discussion
=========================
C++11 allows namespaces to be marked with the inline keyword.
Section 7.3.1:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
"Members of an inline namespace can be used in most respects as
though they were members of the enclosing namespace."
The inline keyword affects how name lookup is performed.
To give a practical example, when a user writes "std::vector<int>", in
libc++ the type is actually a std::__1::vector<int>, with __1 being an
inlined namespace.
This proposal models a C++11 "inline namespace" by attaching the
DW_AT_inline attribute to the namespace.
For discussion: An alternative approach is to emit the inlined
namespaces as if it were imported into the enclosing namespace with a
using directive.
Changes
=======
Section 3.2.2 Namespace Entries
-------------------------------
If a namespace has a DW_AT_inline (DW_INL_declared_inlined) attribute
that namespace is marked as inlined. When a consumer performs name
lookup members of inlined namespaces should be treated as though they
were members of the enclosing namespace.
Section 2.2 Attribute types
---------------------------
[Add "inlined namespace" to DW_AT_inline in Table 2.2: Attribute names]
Appendix A. Attributes by Tag
-----------------------------
[add DW_AT_inline to DW_TAG_namespace]
D.3 Namespace Example
---------------------
[ORIGINAL TEXT]
>>>>>>>>>>>>>>>
namespace A {
namespace B {
int j;
int myfunc (int a);
float myfunc (float f) { return f - 2.0; } int myfunc2(int a) { return a + 2; }
}
}
30$: DW_TAG_variable
DW_AT_name("j")
DW_AT_type(reference to 1$)
DW_AT_location ...
[NEW TEXT]
==========
namespace A {
namespace B {
inline namespace C { // (1) inline namespace
int j;
}
int myfunc (int a);
float myfunc (float f) { return f - 2.0; } int myfunc2(int a) { return a + 2; }
}
}
30$: DW_TAG_namespace
DW_AT_name("C")
DW_AT_inline(DW_INL_declared_inlined)
32$: DW_TAG_variable
DW_AT_name("j")
DW_AT_type(reference to 1$)
DW_AT_location ...
<<<<<<<<<
--
Rejected -- 12/16/2014 (Replaced by 141212.1)