Skip to content

Commit 208e3b0

Browse files
[Clang] Properly deprecate __reference_binds_to_temporary (#141909)
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.
1 parent 54d836a commit 208e3b0

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ Non-comprehensive list of changes in this release
310310
different than before.
311311
- Fixed a crash when a VLA with an invalid size expression was used within a
312312
``sizeof`` or ``typeof`` expression. (#GH138444)
313+
- Deprecation warning is emitted for the deprecated ``__reference_binds_to_temporary`` intrinsic.
314+
``__reference_constructs_from_temporary`` should be used instead. (#GH44056)
313315

314316
New Compiler Flags
315317
------------------

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,9 @@ void DiagnoseBuiltinDeprecation(Sema &S, TypeTrait Kind, SourceLocation KWLoc) {
14581458
case UTT_IsTriviallyRelocatable:
14591459
Replacement = clang::UTT_IsCppTriviallyRelocatable;
14601460
break;
1461+
case BTT_ReferenceBindsToTemporary:
1462+
Replacement = clang::BTT_ReferenceConstructsFromTemporary;
1463+
break;
14611464
default:
14621465
return;
14631466
}

clang/test/SemaCXX/deprecated-builtins.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void f() {
1515
a = __has_trivial_constructor(A); // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
1616
a = __has_trivial_move_constructor(A); // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
1717
a = __has_trivial_destructor(A); // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}
18+
a = __reference_binds_to_temporary(const A&, A); // expected-warning-re {{__reference_binds_to_temporary {{.*}} use __reference_constructs_from_temporary}}
1819

1920
}
2021

0 commit comments

Comments
 (0)