annotate clang/test/Sema/inline-asm-validate-tmpl.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 // this template, when instantiated with 300, violates the range contraint
anatofuz
parents:
diff changeset
6 template <int N> void test(int value)
anatofuz
parents:
diff changeset
7 {
anatofuz
parents:
diff changeset
8 asm("rol %1, %0" :"=r"(value): "I"(N + 1)); // expected-error{{value '301' out of range for constraint 'I'}}
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 int main() { test<300>(10); } // expected-note{{in instantiation of function template specialization 'test<300>' requested here}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 // this template is not used, but the error is detectable
anatofuz
parents:
diff changeset
15 template <int N> void testb(int value)
anatofuz
parents:
diff changeset
16 {
anatofuz
parents:
diff changeset
17 asm("rol %1, %0" :"=r"(value): "I"(301)); // expected-error{{value '301' out of range for constraint 'I'}}
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 // these should compile without error
anatofuz
parents:
diff changeset
21 template <int N> void testc(int value)
anatofuz
parents:
diff changeset
22 {
anatofuz
parents:
diff changeset
23 asm("rol %1, %0" :"=r"(value): "I"(N + 1));
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25 int foo() { testc<2>(10); }
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 // these should compile without error
anatofuz
parents:
diff changeset
28 template <int N> bool testd()
anatofuz
parents:
diff changeset
29 {
anatofuz
parents:
diff changeset
30 __asm goto ("" : : : : lab);
anatofuz
parents:
diff changeset
31 return true;
anatofuz
parents:
diff changeset
32 lab:
anatofuz
parents:
diff changeset
33 return false;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35 bool foox() { return testd<0> (); }