diff --git a/abi.html b/abi.html index b2df8ab..2a1d36b 100644 --- a/abi.html +++ b/abi.html @@ -4503,13 +4503,13 @@
Dependent constructs in templates
Anonymous entities

-For the purposes of mangling, the name of an anonymous union is -considered to be the name of the first named data member found by a +For the purposes of mangling, the name of an anonymous struct or union +is considered to be the name of the first named data member found by a pre-order, depth-first, declaration-order walk of the data members of -the anonymous union. If there is no such data member (i.e., if all of -the data members in the union are unnamed), then there is no way for a -program to refer to the anonymous union, and there is therefore no -need to mangle its name. +the anonymous type. If there is no such data member (i.e., if all of +the data members in the struct or union are unnamed), then there is +no way for a program to refer to the anonymous type, and there is +therefore no need to mangle its name.

@@ -5499,13 +5499,188 @@

5.1.5.10 Template Arguments

-Type arguments appear using their regular encoding. -For example, the template class "A<char, float>" is encoded as "1AIcfE". -A slightly more involved example is -a dependent function parameter type "A<T2>::X" -(T2 is the second template parameter) -which is encoded as "N1AIT0_E1XE", -where the "N...E" construct is used to describe a qualified name. +Template arguments can be dependent when a template argument list +is written in a context where dependent structures must be mangled. +For example, if the parameter type of a function template is +A<T2>::X, where T2 is the second +template parameter of the function template, this is mangled as +N1AIT0_E1XE. + +

+Template type arguments and template template arguments are mangled +using their regular encoding. For example, the class template +specialization A<char, float> is encoded as +1AIcfE. + +

+A non-type template argument is considered dependent if either the +argument expression is instantiation-dependent or it is not matched +with a template parameter of non-dependent type. (The latter can +happen if, for example, the template name is dependent and not a +template parameter.) If so, it is mangled as an expression in the +usual way for a dependent mangling. +Otherwise, it is converted to the template parameter type, +constant-evaluated, and then mangled as a value. For example: + +

+template  class A;
+
+template <class U, template <class T, T N> class Temp> void f(Temp<U, 4+5>) {}
+
+f    // _Z1fIj1AEvT0_IT_XplLi4ELi5EEE
+// The template parameter type is dependent, and so the template
+// argument is mangled as a dependent expression without any
+// constant-folding.
+
+template <template <class T, T N> class Temp> void g(Temp<unsigned, 4+5>) {}
+g    // _Z1gI1AEvT_IjLj9EE
+// The template parameter type is not dependent, and so the template
+// argument is converted to unsigned and constant-evaluated.
+
+ +

+Non-type template argument values of integer, enumerated, +floating-point, or complex type are mangled as +literals of the template parameter +type. Note that this can produce combinations which cannot normally +be written in the source language, such as a literal of +short type. + +

+Non-type template argument values of pointer or member pointer type +that are null are mangled as as a literal 0 of the +template parameter type. For example: + +

+struct A;
+template <void (A::*)()> void f();
+
+f<nullptr> // _Z1fILM1AFvvE0EEvv
+
+ +

+Non-type template argument values of reference or pointer type +are mangled using the subobject +specifier expression for the argument. If this is a simple +declaration reference, it may be mangled as an +<expr-primary>. + +

+Non-type template argument values of member pointer type +that are not null are mangled as expressions applying the +operator & to the member function declaration +as if it were a regular function. (Note that this does not +distinguish between member pointers that have been converted +to different types.) For example: + +

+struct A {
+    void foo();
+};
+template <void (A::*)()> void f();
+
+f<&A::foo> // _Z1fIXadL_ZN1A3fooEvEEEvv
+
+ +

+Non-type template argument values of class type are mangled as +a direct initialization (tl) of the class type +using the member +initiializer sequence for the argument. + + +

5.1.5.11 Subobject specifier expressions
+ + +

+Constant evaluation may result in a pointer or reference to a specific +subobject of an object of static storage duration. This subobject is +identified in the mangling as if written with a specific expression, +called its subobject specifier expression. + +

+(To be specified. See +for now.) + + +

5.1.5.12 Member initializer sequences
+ + +

+The constant evaluation of an expression of class type assigns +a constant value to each non-static data member of the class or, +if the class is a union, to at most one non-static data member, +called the active union member. Under the standard, this exact +structure uniquely determines a value, including whether a union +has an active union member member and (if so) which one. As +different values can produce different template specializations, +this structure must be faithfully represented in the mangling of +a value as a template argument. + +

+A value is converted to a flattened sequence of values by applying +the following expansions until no values of array or non-union class +type remain: +

+Values satisfying the following conditions are then removed from +the end of the sequence until the final value does not satisfy +these conditions or the sequence is empty: + + +

+This sequence is then mangled as a sequence of +<braced-expression>s +as follows: +

+ +

+Note that qualifiers on the type of a non-static data member are not +part of the type of the value stored in that member. + +

+For example: + +

+struct A {
+    int x, y;
+};
+struct B {
+    union { A a; };
+    constexpr B(int x, int y) { a.x = x; a.y = y; }
+};
+
+template <B v> struct C {};
+
+C<0,0> // 1CIXtl1BEEE
+C<1,0> // 1CIXtl1BtlNS0_Ut_Edi1atl1ALi1EEEEEE
+C<1,1> // 1CIXtl1BtlNS0_Ut_Edi1atl1ALi1ELi1EEEEEE
+

5.1.6 Expressions