]> granicus.if.org Git - clang/commitdiff
fix a crash on invalid by making ActOnDeclarator create decl with
authorChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 19:32:54 +0000 (19:32 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 19:32:54 +0000 (19:32 +0000)
a dummy *function* type when it is recovering and knows it needs
a function.  rdar://6802350 - clang crash on invalid input

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69374 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/function.c

index 3b6ce6bd735d7e951716e9cb2ff9cddc42783deb..0fe5715578bd1ef947c35d14f0fad2719c9836e2 100644 (file)
@@ -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.
index 3a0352d753944da5bf71a2a6e6091f448e147586..7e5887a27755b69be62adfd26705dd791e997d0a 100644 (file)
@@ -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'}}
+}
+
+