From cd2a97492ef6f3bd0c01cfcfcb4aa0a803dc76b8 Mon Sep 17 00:00:00 2001 From: Reid Kleckner <reid@kleckner.net> Date: Thu, 6 Mar 2014 19:19:36 +0000 Subject: [PATCH] Add tests for MS inline asm change r203146 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203147 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/ms-inline-asm.c | 15 +++++++++++++++ test/Sema/ms-inline-asm.c | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c index 2c7af2e7d98..318d509cfa4 100644 --- a/test/CodeGen/ms-inline-asm.c +++ b/test/CodeGen/ms-inline-asm.c @@ -445,3 +445,18 @@ void cpuid() { // CHECK-LABEL: define void @cpuid // CHECK: call void asm sideeffect inteldialect "cpuid", "~{eax},~{ebx},~{ecx},~{edx},~{dirflag},~{fpsr},~{flags}"() } + +typedef struct { + int a; + int b; +} A; + +void t39() { + __asm mov eax, [eax].A.b + __asm mov eax, [eax] A.b + __asm mov eax, fs:[0] A.b + // CHECK-LABEL: define void @t39 + // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"() + // CHECK: call void asm sideeffect inteldialect "mov eax, [eax] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"() + // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"() +} diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c index 84346888181..deca6509b83 100644 --- a/test/Sema/ms-inline-asm.c +++ b/test/Sema/ms-inline-asm.c @@ -75,3 +75,29 @@ int t2(int *arr, int i) { //__asm mov eax, [arr + i]; return 0; } + +typedef struct { + int a; + int b; +} A; + +void t3() { + __asm mov eax, [eax] UndeclaredId // expected-error {{unknown token in expression}} + + // FIXME: Only emit one diagnostic here. + // expected-error@+2 {{unexpected type name 'A': expected expression}} + // expected-error@+1 {{unknown token in expression}} + __asm mov eax, [eax] A +} + +void t4() { + // The dot in the "intel dot operator" is optional in MSVC. MSVC also does + // global field lookup, but we don't. + __asm mov eax, [0] A.a + __asm mov eax, [0].A.a + __asm mov eax, [0].a // expected-error {{Unable to lookup field reference!}} + __asm mov eax, fs:[0] A.a + __asm mov eax, fs:[0].A.a + __asm mov eax, fs:[0].a // expected-error {{Unable to lookup field reference!}} + __asm mov eax, fs:[0]. A.a // expected-error {{Unexpected token type!}} +} -- GitLab