inline-asm-validate-tmpl.cpp 846 B

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