[PATCH] D24193: Allow variables with asm labels in naked functions

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 09:41:44 PDT 2016


hans added a comment.

I think this is reasonable. Just a few comments:


================
Comment at: lib/Sema/SemaDecl.cpp:11796
@@ +11795,3 @@
+        if (auto *DS = dyn_cast<DeclStmt>(S)) {
+          if (DS->isSingleDecl()) {
+            if (auto *Var = dyn_cast_or_null<VarDecl>(DS->getSingleDecl())) {
----------------
I think we'll need to check for multiple declarators here:

```
register int x asm("eax"), y asm("ebx");
```

And do we need to check for an initializer? For example, the following should not be allowed:

```
register int x asm("eax") = g();
```

It would also be nice to have a comment explaining why these are Ok but not other declarations.


https://reviews.llvm.org/D24193





More information about the cfe-commits mailing list