[PATCH] Allow a module to require the absence of a feature

Richard Smith richard at metafoo.co.uk
Mon Oct 28 14:54:34 PDT 2013


  Changed Requires to Requirements.

Hi doug.gregor, djasper,

http://llvm-reviews.chandlerc.com/D2027

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2027?vs=5162&id=5204#toc

Files:
  include/clang/Parse/Parser.h
  test/Parser/pragma-weak.c
  test/CodeGen/pragma-weak.c

Index: include/clang/Parse/Parser.h
===================================================================
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -1471,8 +1471,12 @@
   typedef SmallVector<ParsedType, 12> TypeVector;
 
   StmtResult ParseStatement(SourceLocation *TrailingElseLoc = 0) {
-    StmtVector Stmts;
-    return ParseStatementOrDeclaration(Stmts, true, TrailingElseLoc);
+    StmtResult Res;
+    do {
+      StmtVector Stmts;
+      Res = ParseStatementOrDeclaration(Stmts, true, TrailingElseLoc);
+    } while(!Res.isInvalid() && !Res.get());
+    return Res;
   }
   StmtResult ParseStatementOrDeclaration(StmtVector &Stmts,
                                          bool OnlyStatement,
Index: test/Parser/pragma-weak.c
===================================================================
--- test/Parser/pragma-weak.c
+++ test/Parser/pragma-weak.c
@@ -15,3 +15,30 @@
 extern int a;
 /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b
 /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c
+
+
+void pragma_is_not_a_statement(int x)
+{
+  int t;
+
+  {
+    if (x)
+#pragma weak t
+    else // expected-error {{expected expression}}
+#pragma weak t
+  }
+
+  switch (x) {
+    case 1:
+#pragma weak t
+  } // expected-error {{expected statement}}
+  switch(x) {
+    default:
+#pragma weak t
+  } // expected-error {{expected statement}}
+
+label:
+#pragma weak t
+} // expected-error {{expected statement}}
+
+
Index: test/CodeGen/pragma-weak.c
===================================================================
--- test/CodeGen/pragma-weak.c
+++ test/CodeGen/pragma-weak.c
@@ -149,7 +149,29 @@
 }
 // CHECK: declare extern_weak i32 @PR14046e()
 
+// Parse #pragma weak after a label or case statement
+extern int PR16705a(void);
+extern int PR16705b(void);
+extern int PR16705c(void);
+void PR16705f(int a) {
+  switch(a) {
+  case 1:
+#pragma weak PR16705a
+    PR16705a();
+  default:
+#pragma weak PR16705b
+    PR16705b();
+  }
+label:
+  #pragma weak PR16705c
+  PR16705c();
+}
 
+// CHECK: declare extern_weak i32 @PR16705a()
+// CHECK: declare extern_weak i32 @PR16705b()
+// CHECK: declare extern_weak i32 @PR16705c()
+
+
 ///////////// TODO: stuff that still doesn't work
 
 // due to the fact that disparate TopLevelDecls cannot affect each other
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2027.2.patch
Type: text/x-patch
Size: 2360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131028/874debea/attachment.bin>


More information about the cfe-commits mailing list