I think recording the MSAsmStmt in the statement field of the LabelDecl is 
probably the way to go here. Then we can wait until the end of the function to 
check what label went where.

================
Comment at: lib/Parse/ParseStmtAsm.cpp:50
@@ +49,3 @@
+  /// The LabelDecls encountered when parsing the asm block.
+  std::set<LabelDecl*> LabelDecls;
+
----------------
This can be `SmallPtrSet<LabelDecl*, 4>`. Sorry, we have a silly STL allergy. :)

================
Comment at: lib/Parse/ParseStmtAsm.cpp:118
@@ +117,3 @@
+    for (const auto *Label : LabelDecls) {
+      if (!Label->isResolvedMSAsmLabel()) {
+        TheParser.getActions().DiagnoseCrossBlockLabelUse(Label);
----------------
Do we reject this?
  void f(int x) {
    __asm {
    label:
      nop
    }
    x++;
    __asm {
      cmp x, 10
      je label
    }
  }

================
Comment at: test/Sema/ms-inline-asm.c:109
@@ -108,3 +108,3 @@
 __declspec(naked) int t5(int x) { // expected-note {{attribute is here}}
-  asm { movl eax, x } // expected-error {{parameter references not allowed in 
naked functions}} expected-error {{use of undeclared label 'x'}}
+  asm { movl eax, x } // expected-error {{parameter references not allowed in 
naked functions}} expected-error {{use of undeclared label 'x'}} expected-error 
{{cannot use inline assembly label 'x' defined outside of an inline assembly 
block}}
   asm { retl }
----------------
Hm, this diagnostic is pretty bad. :( We should try returning the found 
declaration even when we generate the first diagnostic to suppress these follow 
on diagnostics.

http://reviews.llvm.org/D5694



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to