[clang] [Clang] [Sema] Ensure noexcept(typeid(E)) checks if E throws when needed (PR #95846)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 04:35:38 PDT 2024


================
@@ -115,3 +116,39 @@ static_assert(!noexcept(typeid((Polymorphic<true, false>&&) Polymorphic<true, fa
 static_assert(!noexcept(typeid(*&(const Polymorphic<true, true>&) Polymorphic<true, true>{})));
 static_assert(!noexcept(typeid(*&(const Polymorphic<false, true>&) Polymorphic<false, true>{})));
 static_assert(!noexcept(typeid(*&(const Polymorphic<true, false>&) Polymorphic<true, false>{})));
+
+template<bool B>
+struct X {
+  template<typename T> void f();
+};
+template<typename T>
+void f1() {
+  X<noexcept(typeid(*T{}))> dependent;
+  dependent.f<void>();
+  // expected-error at -1 {{use 'template' keyword to treat 'f' as a dependent template name}}
----------------
Sirraide wrote:

Perhaps I’m just being a bit slow today, but it took me a few seconds to realise that this is testing *whether* the `noexcept(...)` is correctly marked as dependent here; imo that deserves a comment so whoever looks at this next doesn’t end up as confused as I was just now

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


More information about the cfe-commits mailing list