]> granicus.if.org Git - clang/commitdiff
Fix crasher in ASTContext::getObjCEncodingForMethodDecl().
authorSteve Naroff <snaroff@apple.com>
Tue, 14 Apr 2009 00:03:58 +0000 (00:03 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 14 Apr 2009 00:03:58 +0000 (00:03 +0000)
This was exposed as a result of something else that was recently fixed.

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

lib/AST/ASTContext.cpp
test/CodeGen/function-decay.m [new file with mode: 0644]

index f319c3f392ebcdc367b332f5ec98a2674b612414..1c682175b33b9c722b312fe0c445a5bf808f5b6e 100644 (file)
@@ -2081,11 +2081,13 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
     ParmVarDecl *PVDecl = *PI;
     QualType PType = PVDecl->getOriginalType(); 
     if (const ArrayType *AT =
-          dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) 
-        // Use array's original type only if it has known number of
-        // elements.
-        if (!dyn_cast<ConstantArrayType>(AT))
-          PType = PVDecl->getType();
+          dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
+      // Use array's original type only if it has known number of
+      // elements.
+      if (!dyn_cast<ConstantArrayType>(AT))
+        PType = PVDecl->getType();
+    } else if (PType->isFunctionType())
+      PType = PVDecl->getType();
     // Process argument qualifiers for user supplied arguments; such as,
     // 'in', 'inout', etc.
     getObjCEncodingForTypeQualifier(PVDecl->getObjCDeclQualifier(), S);
diff --git a/test/CodeGen/function-decay.m b/test/CodeGen/function-decay.m
new file mode 100644 (file)
index 0000000..9c87113
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang-cc %s -emit-llvm
+
+@interface I0 @end
+@implementation I0
+- (void) im0: (int (void)) a0 {
+}
+@end
+
+void func(int pf(void)) {
+}