diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-08-25 21:31:01 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-08-25 21:31:01 +0000 |
commit | eb4b7051a596560ef4a1846e3714707f44e9dc30 (patch) | |
tree | 594c0010b8352c42c8003c98aab7ee759e0ce040 /lib/Sema/SemaType.cpp | |
parent | c9e56b2a63f023b298d92fc572c0d47538aae964 (diff) |
Do typechecking and codegen for K&R-style function declarations
correctly. Not a regression, but made more obvious by my recent fix
which made function type compatibility checking a bit more strict.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 820a1c85f0..c7876b1151 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -397,14 +397,12 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { D.setInvalidType(true); } - if (!FTI.hasPrototype) { + if (FTI.NumArgs == 0) { // Simple void foo(), where the incoming T is the result type. T = Context.getFunctionTypeNoProto(T); - + } else if (FTI.ArgInfo[0].Param == 0) { // C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition. - if (FTI.NumArgs != 0) - Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration); - + Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration); } else { // Otherwise, we have a function with an argument list that is // potentially variadic. @@ -458,6 +456,13 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { // Do not add 'void' to the ArgTys list. break; } + } else if (!FTI.hasPrototype) { + if (ArgTy->isPromotableIntegerType()) { + ArgTy = Context.IntTy; + } else if (const BuiltinType* BTy = ArgTy->getAsBuiltinType()) { + if (BTy->getKind() == BuiltinType::Float) + ArgTy = Context.DoubleTy; + } } ArgTys.push_back(ArgTy); |