summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/initializer.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-17 00:11:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-17 00:11:41 +0000
commit0a9969b36b16307e6cf60004b108be972c93d336 (patch)
treeb9e216b9ac175f3a86b748a5effc1190bb161793 /clang/test/Analysis/initializer.cpp
parent1c1de452570b525f1a7ed9f7da919e0af16c23bd (diff)
downloadbcm5719-llvm-0a9969b36b16307e6cf60004b108be972c93d336.tar.gz
bcm5719-llvm-0a9969b36b16307e6cf60004b108be972c93d336.zip
Restructure checking for, and warning on, lifetime extension.
This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. llvm-svn: 337226
Diffstat (limited to 'clang/test/Analysis/initializer.cpp')
-rw-r--r--clang/test/Analysis/initializer.cpp23
1 files changed, 0 insertions, 23 deletions
diff --git a/clang/test/Analysis/initializer.cpp b/clang/test/Analysis/initializer.cpp
index b73a94f1dbf..0cb68c4a978 100644
--- a/clang/test/Analysis/initializer.cpp
+++ b/clang/test/Analysis/initializer.cpp
@@ -178,29 +178,6 @@ namespace ReferenceInitialization {
const MyStruct &myStruct(OtherStruct(5));
myStruct.method(); // no-warning
}
-
- struct HasMyStruct {
- const MyStruct &ms; // expected-note {{reference member declared here}}
- const MyStruct &msWithCleanups; // expected-note {{reference member declared here}}
-
- // clang's Sema issues a warning when binding a reference member to a
- // temporary value.
- HasMyStruct() : ms(5), msWithCleanups(OtherStruct(5)) {
- // expected-warning@-1 {{binding reference member 'ms' to a temporary value}}
- // expected-warning@-2 {{binding reference member 'msWithCleanups' to a temporary value}}
-
- // At this point the members are not garbage so we should not expect an
- // analyzer warning here even though binding a reference member
- // to a member is a terrible idea.
- ms.method(); // no-warning
- msWithCleanups.method(); // no-warning
- }
- };
-
- void referenceInitializeField() {
- HasMyStruct hms;
- }
-
};
namespace PR31592 {
OpenPOWER on IntegriCloud