[X86] Move getGFNICtrlMask before CTLZ/CTTZ lowering. NFC.
[llvm-project.git] / clang / test / SemaCXX / warn-dangling-local.cpp
blob5ad5013b6f0253fbe470ddc4b7b71ba7782ce4d4
1 // RUN: %clang_cc1 -verify -std=c++11 -Wdangling-assignment-gsl %s
3 using T = int[];
5 void f() {
6 int *p = &(int&)(int&&)0; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
7 p = &(int&)(int&&)0; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
9 int *q = (int *const &)T{1, 2, 3}; // expected-warning {{temporary whose address is used as value of local variable 'q' will be destroyed at the end of the full-expression}}
10 q = (int *const &)T{1, 2, 3}; // expected-warning {{object backing the pointer q will be destroyed at the end of the full-expression}}
12 // FIXME: We don't warn here because the 'int*' temporary is not const, but
13 // it also can't have actually changed since it was created, so we could
14 // still warn.
15 int *r = (int *&&)T{1, 2, 3};
17 // FIXME: The wording of this warning is not quite right. There are two
18 // temporaries here: an 'int* const' temporary that points to the array, and
19 // is lifetime-extended, and an array temporary that the pointer temporary
20 // points to, which doesn't live long enough.
21 int *const &s = (int *const &)T{1, 2, 3}; // expected-warning {{temporary bound to local reference 's' will be destroyed at the end of the full-expression}}
24 // PR38355
25 void g() {
26 const int a[] = {a[0]};
27 const int b[] = {a[0]};
30 namespace std {
31 // std::basic_string has a hard-coded gsl::owner attr.
32 struct basic_string {
33 const char* c_str();
35 } // namespace std
36 void test(const char* a) {
37 // verify we're emitting the `-Wdangling-assignment-gsl` warning.
38 a = std::basic_string().c_str(); // expected-warning {{object backing the pointer a will be destroyed at the end of the full-expression}}