summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/ms-inline-asm.c
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2014-09-22 02:21:54 +0000
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2014-09-22 02:21:54 +0000
commit31097581aad843ffb85befeeedb2e23a4d8cc287 (patch)
treebb169eaa18a5fcf9baef086f133e1c6d2bafa80a /clang/test/Sema/ms-inline-asm.c
parentdb0e7061c6b45357f83b121d6b97f67104288993 (diff)
downloadbcm5719-llvm-31097581aad843ffb85befeeedb2e23a4d8cc287.tar.gz
bcm5719-llvm-31097581aad843ffb85befeeedb2e23a4d8cc287.zip
ms-inline-asm: Scope inline asm labels to functions
Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
Diffstat (limited to 'clang/test/Sema/ms-inline-asm.c')
-rw-r--r--clang/test/Sema/ms-inline-asm.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/clang/test/Sema/ms-inline-asm.c b/clang/test/Sema/ms-inline-asm.c
index 358b0bd4543..6eac7695054 100644
--- a/clang/test/Sema/ms-inline-asm.c
+++ b/clang/test/Sema/ms-inline-asm.c
@@ -29,7 +29,7 @@ void f() {
}
f();
__asm {
- mov eax, TYPE bar // expected-error {{unable to lookup expression}}
+ mov eax, TYPE bar // expected-error {{unable to lookup expression}} expected-error {{use of undeclared label 'bar'}}
}
}
@@ -80,9 +80,10 @@ typedef struct {
} A;
void t3() {
- __asm { mov eax, [eax] UndeclaredId } // expected-error {{unknown token in expression}}
+ __asm { mov eax, [eax] UndeclaredId } // expected-error {{unknown token in expression}} expected-error {{use of undeclared label 'UndeclaredId'}}
// FIXME: Only emit one diagnostic here.
+ // expected-error@+3 {{use of undeclared label 'A'}}
// expected-error@+2 {{unexpected type name 'A': expected expression}}
// expected-error@+1 {{unknown token in expression}}
__asm { mov eax, [eax] A }
@@ -105,7 +106,7 @@ void test_operand_size() {
}
__declspec(naked) int t5(int x) { // expected-note {{attribute is here}}
- asm { movl eax, x } // expected-error {{parameter references not allowed in naked functions}}
+ asm { movl eax, x } // expected-error {{parameter references not allowed in naked functions}} expected-error {{use of undeclared label 'x'}}
asm { retl }
}
@@ -114,3 +115,36 @@ __declspec(naked) int t6(int x) {
asm { mov eax, y } // No error.
asm { ret }
}
+
+void t7() {
+ __asm {
+ foo: // expected-note {{inline assembly label 'foo' declared here}}
+ mov eax, 0
+ }
+ goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+}
+
+void t8() {
+ __asm foo: // expected-note {{inline assembly label 'foo' declared here}}
+ __asm mov eax, 0
+ goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+}
+
+void t9() {
+ goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+ __asm {
+ foo: // expected-note {{inline assembly label 'foo' declared here}}
+ mov eax, 0
+ }
+}
+
+void t10() {
+ goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+ __asm foo: // expected-note {{inline assembly label 'foo' declared here}}
+ __asm mov eax, 0
+}
+
+void t11() {
+foo:
+ __asm mov eax, foo // expected-error {{use of undeclared label 'foo'}}
+}
OpenPOWER on IntegriCloud