diff options
| author | Steve Naroff <snaroff@apple.com> | 2007-09-10 22:17:00 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2007-09-10 22:17:00 +0000 |
| commit | 4292bde14ff705b2d98d35e79b53a63d4bb1f9c2 (patch) | |
| tree | 1f18445d329d2be276941c2c127abfcd649657a3 /clang/Sema/SemaType.cpp | |
| parent | 8c3c198499b083b94effba8d37152251a5fce42d (diff) | |
| download | bcm5719-llvm-4292bde14ff705b2d98d35e79b53a63d4bb1f9c2.tar.gz bcm5719-llvm-4292bde14ff705b2d98d35e79b53a63d4bb1f9c2.zip | |
Fix the following bug submitted by Justin Handville.
int main(int argc, char* argv[])
{
return 0;
}
After speaking briefly with Chris, we decided this should be a front-end fix.
The fix...have Sema::GetTypeForDeclarator() do the default function/array conversion, as
I outlined in the 9/9 email on this topic.
Since this conversion is done before Sema::ParseParamDeclarator(), I thought I could
remove the conversion from Sema::ParseParamDeclarator(). Unfortunately, this didn't work.
The conversion apparently needs to be done in both places (which doesn't make sense to me).
Will investigate.
llvm-svn: 41811
Diffstat (limited to 'clang/Sema/SemaType.cpp')
| -rw-r--r-- | clang/Sema/SemaType.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/Sema/SemaType.cpp b/clang/Sema/SemaType.cpp index 75f07d8d54b..bf8d48b553d 100644 --- a/clang/Sema/SemaType.cpp +++ b/clang/Sema/SemaType.cpp @@ -261,11 +261,28 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) { QualType ArgTy = QualType::getFromOpaquePtr(FTI.ArgInfo[i].TypeInfo); assert(!ArgTy.isNull() && "Couldn't parse type?"); - + // + // Perform the default function/array conversion (C99 6.7.5.3p[7,8]). + // This matches the conversion that is done in + // Sema::ParseParamDeclarator(). Without this conversion, the + // argument type in the function prototype *will not* match the + // type in ParmVarDecl (which makes the code generator unhappy). + // + // FIXME: We still apparently need the conversion in + // Sema::ParseParamDeclarator(). This doesn't make any sense, since + // it should be driving off the type being created here. + // + // FIXME: If a source translation tool needs to see the original type, + // then we need to consider storing both types somewhere... + // + if (const ArrayType *AT = ArgTy->getAsArrayType()) + ArgTy = Context.getPointerType(AT->getElementType()); + else if (ArgTy->isFunctionType()) + ArgTy = Context.getPointerType(ArgTy); // Look for 'void'. void is allowed only as a single argument to a // function with no other parameters (C99 6.7.5.3p10). We record // int(void) as a FunctionTypeProto with an empty argument list. - if (ArgTy->isVoidType()) { + else if (ArgTy->isVoidType()) { // If this is something like 'float(int, void)', reject it. 'void' // is an incomplete type (C99 6.2.5p19) and function decls cannot // have arguments of incomplete type. |

