================ @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s + +auto&& f1() { + return 42; // expected-error{{returning reference to local temporary object}} +} +const double& f2() { + static int x = 42; + return x; // expected-error{{returning reference to local temporary object}} +} +auto&& id(auto&& r) { + return static_cast<decltype(r)&&>(r); +} +auto&& f3() { + return id(42); // OK, but probably a bug +} + +static_assert(__is_convertible(int, const int &)); +static_assert(__is_nothrow_convertible(int, const int &)); ---------------- frederick-vs-ja wrote:
I think these should go to `clang/test/SemaCXX/type-traits.cpp` (and be unconditionally tested). Note that test coverage for `__is_convertible` is already present. https://github.com/llvm/llvm-project/blob/4b10ade1a6afa1fcff5752aaebd86a1611d499d7/clang/test/SemaCXX/type-traits.cpp#L2556-L2560 But test coverage for `__is_nothrow_convertible` where destination types are references seems missing. Perhaps we should add it in another PR. https://github.com/llvm/llvm-project/pull/89942 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits