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
Fix crash with align_value diagnostic reporting (#135013)
We were passing the address of a local variable to a call to Diag()
which then tried to use the object after its lifetime ended, resulting
in crashes. We no longer pass the temporary object any longer.
Fixes#26612
Copy file name to clipboardExpand all lines: clang/test/SemaCXX/align_value.cpp
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,3 +24,17 @@ struct nope {
24
24
// expected-note@+1 {{in instantiation of template class 'nope<long double, 4>' requested here}}
25
25
nope<longdouble, 4> y2;
26
26
27
+
namespaceGH26612 {
28
+
// This used to crash while issuing the diagnostic about only applying to a
29
+
// pointer or reference type.
30
+
// FIXME: it would be ideal to only diagnose once rather than twice. We get one
31
+
// diagnostic from explicit template arguments and another one for deduced
32
+
// template arguments, which seems silly.
33
+
template <classT>
34
+
voidf(T __attribute__((align_value(4))) x) {} // expected-warning 2 {{'align_value' attribute only applies to a pointer or reference ('int' is invalid)}}
35
+
36
+
voidfoo() {
37
+
f<int>(0); // expected-note {{while substituting explicitly-specified template arguments into function template 'f'}} \
38
+
expected-note {{while substituting deduced template arguments into function template 'f' [with T = int]}}
dependent_param_func<float>(1); // expected-note {{in instantiation of function template specialization 'dependent_param_func<float>' requested here}}
49
49
}
50
+
51
+
namespaceGH26612 {
52
+
// This issue was about the align_value attribute, but alloc_align has the
53
+
// same problematic code pattern, so is being fixed at the same time despite
54
+
// not having the same crashing behavior.
55
+
template <classT>
56
+
__attribute__((alloc_align(1))) T f(T x); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
57
+
58
+
voidfoo() {
59
+
f<int>(0); // expected-note {{in instantiation of function template specialization 'GH26612::f<int>' requested here}}
Copy file name to clipboardExpand all lines: clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -91,3 +91,14 @@ void test24() {
91
91
atest5<s3>(); // expected-note {{in instantiation of function template specialization 'atest5<s3>' requested here}}
92
92
}
93
93
94
+
namespaceGH26612 {
95
+
// This issue was about the align_value attribute, but assume_aligned has the
96
+
// same problematic code pattern, so is being fixed at the same time despite
97
+
// not having the same crashing behavior.
98
+
template <classT>
99
+
__attribute__((assume_aligned(4))) T f(T x); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers or references}}
100
+
101
+
voidfoo() {
102
+
f<int>(0); // expected-note {{in instantiation of function template specialization 'GH26612::f<int>' requested here}}
0 commit comments