summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-17 19:32:54 +0000
committerChris Lattner <sabre@nondot.org>2009-04-17 19:32:54 +0000
commitfbbf539c45b09034c4398dc0c3570ee4270f4a41 (patch)
tree6799bb6f06fc2e590cecc3fbc819b9ca9ad0b2ed
parentc95701da6c41c28c45367c245c44304aed075c26 (diff)
downloadbcm5719-llvm-fbbf539c45b09034c4398dc0c3570ee4270f4a41.tar.gz
bcm5719-llvm-fbbf539c45b09034c4398dc0c3570ee4270f4a41.zip
fix a crash on invalid by making ActOnDeclarator create decl with
a dummy *function* type when it is recovering and knows it needs a function. rdar://6802350 - clang crash on invalid input llvm-svn: 69374
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
-rw-r--r--clang/test/Sema/function.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3b6ce6bd735..0fe5715578b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1327,6 +1327,9 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, bool IsFunctionDefinition) {
if (R.isNull()) {
InvalidDecl = true;
R = Context.IntTy;
+ if (IsFunctionDefinition) // int(...)
+ R = Context.getFunctionType(R, 0, 0, true, 0);
+
}
// See if this is a redefinition of a variable in the same scope.
diff --git a/clang/test/Sema/function.c b/clang/test/Sema/function.c
index 3a0352d7539..7e5887a2775 100644
--- a/clang/test/Sema/function.c
+++ b/clang/test/Sema/function.c
@@ -70,3 +70,10 @@ void gnu_inline1() {}
void
__attribute__((__gnuc_inline__)) // expected-warning {{'gnuc_inline' attribute requires function to be marked 'inline', attribute ignored}} expected-warning{{extension used}}
gnu_inline2() {}
+
+
+// rdar://6802350
+inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
+}
+
+
OpenPOWER on IntegriCloud