You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// evaluation: I think it's still taking 'x' as being null from the call to
922
922
// f3() rather than tracking the assignment happening in the VLA.
923
-
constexprintf3(int *x, int (*y)[*(x=(int[]){1,2,3})]) { // both-warning {{object backing the pointer x will be destroyed at the end of the full-expression}}
923
+
constexprintf3(int *x, int (*y)[*(x=(int[]){1,2,3})]) { // both-warning {{object backing the pointer 'x' will be destroyed at the end of the full-expression}}
924
924
return x[0]; // both-note {{read of dereferenced null pointer is not allowed in a constant expression}}
925
925
}
926
926
constexprint h = f3(0,0); // both-error {{constexpr variable 'h' must be initialized by a constant expression}} \
Copy file name to clipboardExpand all lines: clang/test/C/C11/n1285.c
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -32,51 +32,51 @@ void sink(int *);
32
32
33
33
intfunc_return(void) {
34
34
int*p=f().a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
35
-
p=f().a; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
36
-
p=g().a; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
35
+
p=f().a; // expected-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
36
+
p=g().a; // expected-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
37
37
sink(f().a); // Ok
38
38
return*f().a; // Ok
39
39
}
40
40
41
41
intternary(void) {
42
42
int*p= (1 ? (structX){ 0 } : f()).a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
43
43
int*r= (1 ? (unionU){ 0 } : g()).a; // expected-warning {{temporary whose address is used as value of local variable 'r' will be destroyed at the end of the full-expression}}
44
-
p= (1 ? (structX){ 0 } : f()).a; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
44
+
p= (1 ? (structX){ 0 } : f()).a; // expected-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
45
45
sink((1 ? (structX){ 0 } : f()).a); // Ok
46
46
47
47
// This intentionally gets one diagnostic in C and two in C++. In C, the
48
48
// compound literal results in an lvalue, not an rvalue as it does in C++. So
49
49
// only one branch results in a temporary in C but both branches do in C++.
50
50
int*q=1 ? (structX){ 0 }.a : f().a; // expected-warning {{temporary whose address is used as value of local variable 'q' will be destroyed at the end of the full-expression}} \
51
51
cpp-warning {{temporary whose address is used as value of local variable 'q' will be destroyed at the end of the full-expression}}
52
-
q=1 ? (structX){ 0 }.a : f().a; // expected-warning {{object backing the pointer q will be destroyed at the end of the full-expression}} \
53
-
cpp-warning {{object backing the pointer q will be destroyed at the end of the full-expression}}
54
-
q=1 ? (structX){ 0 }.a : g().a; // expected-warning {{object backing the pointer q will be destroyed at the end of the full-expression}} \
55
-
cpp-warning {{object backing the pointer q will be destroyed at the end of the full-expression}}
52
+
q=1 ? (structX){ 0 }.a : f().a; // expected-warning {{object backing the pointer 'q' will be destroyed at the end of the full-expression}} \
53
+
cpp-warning {{object backing the pointer 'q' will be destroyed at the end of the full-expression}}
54
+
q=1 ? (structX){ 0 }.a : g().a; // expected-warning {{object backing the pointer 'q' will be destroyed at the end of the full-expression}} \
55
+
cpp-warning {{object backing the pointer 'q' will be destroyed at the end of the full-expression}}
56
56
sink(1 ? (structX){ 0 }.a : f().a); // Ok
57
57
return*(1 ? (structX){ 0 }.a : f().a); // Ok
58
58
}
59
59
60
60
intcomma(void) {
61
61
structXx;
62
62
int*p= ((void)0, x).a; // c-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
63
-
p= ((void)0, x).a; // c-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
63
+
p= ((void)0, x).a; // c-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
64
64
sink(((void)0, x).a); // Ok
65
65
return*(((void)0, x).a);// Ok
66
66
}
67
67
68
68
intcast(void) {
69
69
structXx;
70
70
int*p= ((structX)x).a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
71
-
p= ((structX)x).a; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
71
+
p= ((structX)x).a; // expected-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
72
72
sink(((structX)x).a); // Ok
73
73
return*(((structX)x).a); // Ok
74
74
}
75
75
76
76
intassign(void) {
77
77
structXx, s;
78
78
int*p= (x=s).a; // c-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
79
-
p= (x=s).a; // c-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
79
+
p= (x=s).a; // c-warning {{object backing the pointer 'p' will be destroyed at the end of the full-expression}}
0 commit comments