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