================
@@ -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}}
----------------
akash-manna-sky wrote:

Makes sense! I added them to show the dependent path still checks at 
instantiation, but `test9` already covers that which I missed. Dropped them, 
along with `bar2`. 


https://github.com/llvm/llvm-project/pull/233112
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to