[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: [PATCH] Fix crash parsing pragma after a case or a default
From: Olivier Goffart <ogoffart () kde ! org>
Date: 2013-09-15 19:23:26
Message-ID: 2233860.W2QG8Km8HY () gargamel
[Download RAW message or body]
Hi,
The attached patch fix a crash when there are pragma in case statement.
(Seen while parsing glibc source code)
void __td_ta_lookup_th_unique()
{
int t = 0;
switch (t)
{
case 1:
#pragma weak t
;
}
}
http://llvm.org/bugs/show_bug.cgi?id=16705
Regards
--
Olivier
["0001-Fix-crash-when-there-is-a-pragma-right-after-a-case-.patch" (0001-Fix-crash-when-there-is-a-pragma-right-after-a-case-.patch)]
From c00ce7aa9c04d8c12123ab86f0984b54b26d8ab0 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@woboq.com>
Date: Thu, 25 Jul 2013 14:43:11 +0200
Subject: [PATCH] Fix crash when there is a pragma right after a case
statement
---
lib/Parse/ParseStmt.cpp | 4 ++--
test/CodeGen/pragma-weak.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index b74ab25..1d34c5a 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -627,7 +627,7 @@ StmtResult Parser::ParseCaseStatement(bool MissingCase, ExprResult Expr) {
}
// Broken sub-stmt shouldn't prevent forming the case statement properly.
- if (SubStmt.isInvalid())
+ if (!SubStmt.isUsable())
SubStmt = Actions.ActOnNullStmt(SourceLocation());
// Install the body into the most deeply-nested case.
@@ -676,7 +676,7 @@ StmtResult Parser::ParseDefaultStatement() {
}
// Broken sub-stmt shouldn't prevent forming the case statement properly.
- if (SubStmt.isInvalid())
+ if (!SubStmt.isUsable())
SubStmt = Actions.ActOnNullStmt(ColonLoc);
return Actions.ActOnDefaultStmt(DefaultLoc, ColonLoc,
diff --git a/test/CodeGen/pragma-weak.c b/test/CodeGen/pragma-weak.c
index 9bfb9ea..eec029e 100644
--- a/test/CodeGen/pragma-weak.c
+++ b/test/CodeGen/pragma-weak.c
@@ -165,6 +165,22 @@ void PR14046f() {
}
// CHECK: declare extern_weak i32 @PR14046e()
+// Parse #pragma weak in a case or default statement
+extern int PR16705a(void);
+extern int PR16705b(void);
+int PR16705f(int a) {
+ switch(a) {
+ case 1:
+#pragma weak PR16705a
+ PR16705a();
+ default:
+#pragma weak PR16705b
+ PR16705b();
+ }
+}
+// CHECK: declare extern_weak i32 @PR16705a()
+// CHECK: declare extern_weak i32 @PR16705b()
+
///////////// TODO: stuff that still doesn't work
--
1.7.12.1
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic