xref: /aosp_15_r20/external/clang/test/Sema/inline-asm-validate-tmpl.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
2*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
3*67e74705SXin Li 
4*67e74705SXin Li 
5*67e74705SXin Li // this template, when instantiated with 300, violates the range contraint
test(int value)6*67e74705SXin Li template <int N> void	test(int value)
7*67e74705SXin Li {
8*67e74705SXin Li   asm("rol %1, %0" :"=r"(value): "I"(N + 1)); // expected-error{{value '301' out of range for constraint 'I'}}
9*67e74705SXin Li }
10*67e74705SXin Li 
main()11*67e74705SXin Li int		main() { test<300>(10); } // expected-note{{in instantiation of function template specialization 'test<300>' requested here}}
12*67e74705SXin Li 
13*67e74705SXin Li 
14*67e74705SXin Li // this template is not used, but the error is detectable
testb(int value)15*67e74705SXin Li template <int N> void	testb(int value)
16*67e74705SXin Li {
17*67e74705SXin Li    asm("rol %1, %0" :"=r"(value): "I"(301)); // expected-error{{value '301' out of range for constraint 'I'}}
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li // these should compile without error
testc(int value)21*67e74705SXin Li template <int N> void	testc(int value)
22*67e74705SXin Li {
23*67e74705SXin Li 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
24*67e74705SXin Li }
foo()25*67e74705SXin Li int	foo() { testc<2>(10); }
26