sammccall added a comment. Ugh, the hole goes deeper, because the Itanium ABI unambiguously follows the C++11 (instantiation-dependent) behavior. Definitely need Richard's input here as I'm fairly sure this will break things as-is.
================ Comment at: clang/test/CodeGenCXX/mangle-exprs.cpp:215 namespace test5 { template <typename T> void a(decltype(noexcept(T()))) {} ---------------- Amusingly, both GCC and MSVC reject this valid code. GCC says: "sorry, unimplemented: mangling noexcept_expr" MSVC says: "'void test5::a(bool)': no function template defined that matches forced instantiation" MSVC seems to require the expression to be exactly the same as that in the template declaration in order to compile (even when that's not possible)... ================ Comment at: clang/test/CodeGenCXX/mangle.cpp:805 - // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE + // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvm template void f<int>(decltype(sizeof(1))); ---------------- GCC mangles this as `_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE`, so we're breaking compat here :-\ And in fact we're just incorrect. https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling: > If the operand expression of decltype is not instantiation-dependent then the > resulting type is encoded directly. Here, instantiation-dependent *is* explicitly defined as "type-dependent or value-dependent or ...". And therefore these cases must not be "encoded directly", including the motivating case (decltype(N) where N is a typed constant whose initializer is value-dependent). We could consider not two but *three* types of decltypetypes: - decltype(type-dependent), which is sugar for a canonical DependentDeclTypeType - decltype(instantiation-but-not-type-dependent), which is still sugar for a concrete canonical type (per C++17) but mangles using the expr (per cxxabi) - decltype(non-dependent), which is sugar for a concrete canonical type and mangles directly This only works if it's OK for mangling to depend on non-canonical type details - I don't know whether this is the case. @rsmith - any hints here? ================ Comment at: clang/test/SemaTemplate/dependent-expr.cpp:132 } - template void f<int>(); // expected-note {{instantiation of}} + template void f<int>(); ---------------- Took me a while to understand this, I think this is an improvement as we now diagnose when we see the template rather than when we see the instantiation. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87349/new/ https://reviews.llvm.org/D87349 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits