diff options
author | Alexander Musman <alexander.musman@gmail.com> | 2015-06-05 13:40:59 +0000 |
---|---|---|
committer | Alexander Musman <alexander.musman@gmail.com> | 2015-06-05 13:40:59 +0000 |
commit | eae29e247e6b7a0d5fdbd7b1b912278f3cfcb926 (patch) | |
tree | a68b8459d628d3b3effab82427ab3306b9612661 /clang/test/Sema/asm.c | |
parent | 5a589ad6035e2cc6776cc8fb255c27b38cab6c5c (diff) | |
download | bcm5719-llvm-eae29e247e6b7a0d5fdbd7b1b912278f3cfcb926.tar.gz bcm5719-llvm-eae29e247e6b7a0d5fdbd7b1b912278f3cfcb926.zip |
Fix for PR14269: Clang crashes when a bit field is used as inline assembler
input / output with memory constraint.
One generally can't get address of a bit field, so the general solution is to
error on such cases. GCC does the same.
Patch by Andrey Bokhanko
Differential Revision: http://reviews.llvm.org/D10086
llvm-svn: 239153
Diffstat (limited to 'clang/test/Sema/asm.c')
-rw-r--r-- | clang/test/Sema/asm.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index 6c6f3f398e3..1a1e02993a7 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -204,3 +204,20 @@ void fn6() { : "=rm"(a), "=rm"(a) : "11m"(a)) // expected-error {{invalid input constraint '11m' in asm}} } + +// PR14269 +typedef struct test16_foo { + unsigned int field1 : 1; + unsigned int field2 : 2; + unsigned int field3 : 3; +} test16_foo; +test16_foo x; +void test16() +{ + __asm__("movl $5, %0" + : "=rm" (x.field2)); // expected-error {{reference to a bit-field in asm output with a memory constraint '=rm'}} + __asm__("movl $5, %0" + : + : "m" (x.field3)); // expected-error {{reference to a bit-field in asm input with a memory constraint 'm'}} +} + |