[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / clang / test / Sema / inline-asm-validate-tmpl.cpp
blob9e234caa9c8dff5c00d7b579359f4555a14f6a95
1 // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
5 // this template, when instantiated with 300, violates the range contraint
6 template <int N> void test(int value)
8 asm("rol %1, %0" :"=r"(value): "I"(N + 1)); // expected-error{{value '301' out of range for constraint 'I'}}
11 int main() { test<300>(10); } // expected-note{{in instantiation of function template specialization 'test<300>' requested here}}
14 // this template is not used, but the error is detectable
15 template <int N> void testb(int value)
17 asm("rol %1, %0" :"=r"(value): "I"(301)); // expected-error{{value '301' out of range for constraint 'I'}}
20 // these should compile without error
21 template <int N> void testc(int value)
23 asm("rol %1, %0" :"=r"(value): "I"(N + 1));
25 int foo() { testc<2>(10); }
27 // these should compile without error
28 template <int N> bool testd()
30 __asm goto ("" : : : : lab);
31 return true;
32 lab:
33 return false;
35 bool foox() { return testd<0> (); }