]> granicus.if.org Git - clang/commitdiff
Sema::ActOnMethodDeclaration(): Make sure we perform the default function/array conve...
authorSteve Naroff <snaroff@apple.com>
Tue, 9 Dec 2008 19:36:17 +0000 (19:36 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 9 Dec 2008 19:36:17 +0000 (19:36 +0000)
This fixes <rdar://problem/6424064> checker on xcode: (possible bad AST) can the type of a method parameter really have "isFunctionType() == true"?
and http://llvm.org/bugs/show_bug.cgi?id=2997.

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

lib/Sema/SemaDeclObjC.cpp

index 5e9e2b21e2d8ea640f06dd5996c55e25f6b37ae9..308c125d9ae5aadcdbd09753b8b0b88f9fcf3f88 100644 (file)
@@ -1227,9 +1227,14 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
     // FIXME: arg->AttrList must be stored too!
     QualType argType;
     
-    if (ArgTypes[i])
+    if (ArgTypes[i]) {
       argType = QualType::getFromOpaquePtr(ArgTypes[i]);
-    else
+      // Perform the default array/function conversions (C99 6.7.5.3p[7,8]).
+      if (argType->isArrayType()) // (char *[]) -> (char **)
+        argType = Context.getArrayDecayedType(argType);
+      else if (argType->isFunctionType())
+        argType = Context.getPointerType(argType);
+    } else
       argType = Context.getObjCIdType();
     ParmVarDecl* Param = ParmVarDecl::Create(Context, ObjCMethod,
                                              SourceLocation(/*FIXME*/),