-
Notifications
You must be signed in to change notification settings - Fork 14k
[Clang] Properly deprecate __reference_binds_to_temporary
#141909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] Properly deprecate __reference_binds_to_temporary
#141909
Conversation
At the time `__reference_constructs_from_temporary` got implemented, `__reference_binds_to_temporary` was mentioned as deprecated in `LanguageExtensions.rst`, but no deprecation warning was emitted. This PR adds the previously missing warning.
@llvm/pr-subscribers-clang Author: A. Jiang (frederick-vs-ja) ChangesAt the time Closes #44056. Full diff: https://github.com/llvm/llvm-project/pull/141909.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32266fce4d3cb..e1ff28e684af5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -310,6 +310,8 @@ Non-comprehensive list of changes in this release
different than before.
- Fixed a crash when a VLA with an invalid size expression was used within a
``sizeof`` or ``typeof`` expression. (#GH138444)
+- Deprecation warning is emitted for the deprecated ``__reference_binds_to_temporary`` intrinsic.
+ ``__reference_constructs_from_temporary`` should be used instead. (#GH44056)
New Compiler Flags
------------------
diff --git a/clang/lib/Sema/SemaTypeTraits.cpp b/clang/lib/Sema/SemaTypeTraits.cpp
index 7bf3c8eaabf4b..04f54d7044e4f 100644
--- a/clang/lib/Sema/SemaTypeTraits.cpp
+++ b/clang/lib/Sema/SemaTypeTraits.cpp
@@ -1458,6 +1458,9 @@ void DiagnoseBuiltinDeprecation(Sema &S, TypeTrait Kind, SourceLocation KWLoc) {
case UTT_IsTriviallyRelocatable:
Replacement = clang::UTT_IsCppTriviallyRelocatable;
break;
+ case BTT_ReferenceBindsToTemporary:
+ Replacement = clang::BTT_ReferenceConstructsFromTemporary;
+ break;
default:
return;
}
diff --git a/clang/test/SemaCXX/deprecated-builtins.cpp b/clang/test/SemaCXX/deprecated-builtins.cpp
index fafc1da4da13e..1234c8354fcab 100644
--- a/clang/test/SemaCXX/deprecated-builtins.cpp
+++ b/clang/test/SemaCXX/deprecated-builtins.cpp
@@ -15,6 +15,7 @@ void f() {
a = __has_trivial_constructor(A); // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
a = __has_trivial_move_constructor(A); // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
a = __has_trivial_destructor(A); // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}
+ a = __reference_binds_to_temporary(const A&, A); // expected-warning-re {{__reference_binds_to_temporary {{.*}} use __reference_constructs_from_temporary}}
}
|
This comment was marked as resolved.
This comment was marked as resolved.
Documentation build failure is probably unrelated and being fixed in #142387. |
At the time
__reference_constructs_from_temporary
got implemented,__reference_binds_to_temporary
was mentioned as deprecated inLanguageExtensions.rst
, but no deprecation warning was emitted. This PR adds the previously missing warning.Closes #44056.