================
@@ -102,3 +102,54 @@ void foo() {
f<int>(0); // expected-note {{in instantiation of function template
specialization 'GH26612::f<int>' requested here}}
}
} // namespace GH26612
+
+namespace GH194289 {
+template<int qux>
+void bar() { // expected-note {{'bar' declared here}} expected-note {{possible
target for call}}
+ int foo = (int *) __builtin_assume_aligned(baz, qux + 1);
+ // expected-error@-1 {{use of undeclared identifier 'baz'; did you mean
'bar'?}}
+ // expected-error@-2 {{reference to overloaded function could not be
resolved}}
+ // expected-error@-3 {{cannot initialize a variable of type 'int'}}
+}
+
+template<int qux>
+void bar2() { // expected-note {{'bar2' declared here}} expected-note
{{possible target for call}}
+ (void)__builtin_assume_aligned(baz2, 8);
+ // expected-error@-1 {{use of undeclared identifier 'baz2'; did you mean
'bar2'?}}
+ // expected-error@-2 {{reference to overloaded function could not be
resolved}}
+}
+
+void qux_fn(); // expected-note 2 {{'qux_fn' declared here}}
+void typo_to_function() {
+ (void)__builtin_assume_aligned(qux_fm, 8); // expected-error {{use of
undeclared identifier 'qux_fm'; did you mean 'qux_fn'?}}
+ (void)__builtin_assume_aligned(no_such_pointer, 8); // expected-error {{use
of undeclared identifier 'no_such_pointer'}}
+}
+
+template<int N>
+void typo_to_function_tmpl() {
+ (void)__builtin_assume_aligned(qux_fm, 8); // expected-error {{use of
undeclared identifier 'qux_fm'; did you mean 'qux_fn'?}}
+ (void)__builtin_assume_aligned(no_such_pointer, N); // expected-error {{use
of undeclared identifier 'no_such_pointer'}}
+}
+
+template<int N> void aligned_to(int *p) { (void)__builtin_assume_aligned(p,
N); } // expected-error 3 {{requested alignment is not a power of 2}}
----------------
ChenMiaoi wrote:
Could we trim the `aligned_to`, `aligned_to_ull`, `dep_ptr`, `dep_both`,
`dep_off`, and `dep_off_ty` tests and their instantiations? They already pass
without the fix and don't exercise the newly handled conversion-failure path.
The typo_to_function variants could also be trimmed. Keeping the original
reproducer and the focused C/C++ cases where converting the first argument
fails should provide sufficient coverage for this change.
https://github.com/llvm/llvm-project/pull/233112
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits