diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-18 13:23:23 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-18 13:23:23 +0000 |
commit | 5ddf70f1e736d4919c147cf938c8f20b0d17dd00 (patch) | |
tree | 2f652b8c8a7d101fd301199c6c7b461a4f114ca3 | |
parent | 0579c165aa54840898956703ebd63bdd1f4dd907 (diff) |
Reject asm output constraints that consist of modifiers only.
Fixes PR15759.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179756 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Basic/TargetInfo.cpp | 2 | ||||
-rw-r--r-- | test/Sema/asm.c | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 70ea2351ec..699f7d4b3f 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -373,7 +373,7 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const { Name++; } - return true; + return Info.allowsMemory() || Info.allowsRegister(); } bool TargetInfo::resolveSymbolicName(const char *&Name, diff --git a/test/Sema/asm.c b/test/Sema/asm.c index 2c600854bf..c81f16a387 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -130,3 +130,19 @@ void test14(struct S *s) { __asm("": : "a"(*s)); // expected-error {{dereference of pointer to incomplete type 'struct S'}} __asm("": "=a" (*s) :); // expected-error {{dereference of pointer to incomplete type 'struct S'}} } + +// PR15759. +double test15() { + double ret = 0; + __asm("0.0":"="(ret)); // expected-error {{invalid output constraint '=' in asm}} + __asm("0.0":"=&"(ret)); // expected-error {{invalid output constraint '=&' in asm}} + __asm("0.0":"+?"(ret)); // expected-error {{invalid output constraint '+?' in asm}} + __asm("0.0":"+!"(ret)); // expected-error {{invalid output constraint '+!' in asm}} + __asm("0.0":"+#"(ret)); // expected-error {{invalid output constraint '+#' in asm}} + __asm("0.0":"+*"(ret)); // expected-error {{invalid output constraint '+*' in asm}} + __asm("0.0":"=%"(ret)); // expected-error {{invalid output constraint '=%' in asm}} + __asm("0.0":"=,="(ret)); // expected-error {{invalid output constraint '=,=' in asm}} + __asm("0.0":"=,g"(ret)); // no-error + __asm("0.0":"=g"(ret)); // no-error + return ret; +} |