[lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 13 07:33:37 PST 2024


================
@@ -25,7 +25,7 @@ template <int &> struct S {}; // #dr1801-S
 S<i> V; // #dr1801-S-i
 // cxx98-14-error at -1 {{non-type template argument does not refer to any declaration}}
 //   cxx98-14-note@#dr1801-S {{template parameter is declared here}}
-// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject '.i'}}
+// cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject '.i'}}
----------------
Endilll wrote:

Quoting P1907R1 wording changes:
> For a non-type template-parameter of reference or pointer type <...> the reference or pointer value shall not refer to or be the address of (respectively):
> ~a subobject (6.7.2),~
> <...>
> a subobject (6.7.2) of one of the above.

My reading is that you indeed can reference subobjects in NTTP since 20, unless they fall into one of the narrow categories listed in that paragraph. The change you made is correct, unless P1907R1 was adopted as a DR.

Sorry I forgot to check current wording when I added the test.

https://github.com/llvm/llvm-project/pull/78041


More information about the cfe-commits mailing list