1 // RUN: %clang_cc1 -verify=wrong -std=c99 %s
2 // RUN: %clang_cc1 -verify=wrong -std=c11 %s
3 // RUN: %clang_cc1 -verify=cpp -std=c++11 -x c++ %s
4
5 /* WG14 N1285: No
6 * Extending the lifetime of temporary objects (factored approach)
7 *
8 * NB: we do not properly materialize temporary expressions in situations where
9 * it would be expected; that is why the "no-diagnostics" marking is named
10 * "wrong". We do issue the expected diagnostic in C++ mode.
11 */
12
13 // wrong-no-diagnostics
14
15 struct X { int a[5]; };
16 struct X f(void);
17
foo(void)18 int foo(void) {
19 // FIXME: This diagnostic should be issued in C11 as well (though not in C99,
20 // as this paper was a breaking change between C99 and C11).
21 int *p = f().a; // cpp-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
22 return *p;
23 }
24
25