Parameter/argument terminology fixes

llvm-svn: 208499
This commit is contained in:
Alp Toker 2014-05-11 16:06:11 +00:00
parent 4284c6e7a4
commit 1b13dab608
4 changed files with 32 additions and 30 deletions

View File

@ -234,8 +234,8 @@ def ext_implicit_function_decl : ExtWarn<
InGroup<ImplicitFunctionDeclare>; InGroup<ImplicitFunctionDeclare>;
def note_function_suggestion : Note<"did you mean %0?">; def note_function_suggestion : Note<"did you mean %0?">;
def err_ellipsis_first_arg : Error< def err_ellipsis_first_param : Error<
"ISO C requires a named argument before '...'">; "ISO C requires a named parameter before '...'">;
def err_declarator_need_ident : Error<"declarator requires an identifier">; def err_declarator_need_ident : Error<"declarator requires an identifier">;
def err_language_linkage_spec_unknown : Error<"unknown linkage language">; def err_language_linkage_spec_unknown : Error<"unknown linkage language">;
def err_language_linkage_spec_not_ascii : Error< def err_language_linkage_spec_not_ascii : Error<
@ -498,8 +498,8 @@ def err_opencl_half_load_store : Error<
def err_opencl_cast_to_half : Error<"casting to type %0 is not allowed">; def err_opencl_cast_to_half : Error<"casting to type %0 is not allowed">;
def err_opencl_half_declaration : Error< def err_opencl_half_declaration : Error<
"declaring variable of type %0 is not allowed">; "declaring variable of type %0 is not allowed">;
def err_opencl_half_argument : Error< def err_opencl_half_param : Error<
"declaring function argument of type %0 is not allowed; did you forget * ?">; "declaring function parameter of type %0 is not allowed; did you forget * ?">;
def err_opencl_half_return : Error< def err_opencl_half_return : Error<
"declaring function return value of type %0 is not allowed; did you forget * ?">; "declaring function return value of type %0 is not allowed; did you forget * ?">;
def warn_enum_value_overflow : Warning<"overflow in enumeration value">; def warn_enum_value_overflow : Warning<"overflow in enumeration value">;

View File

@ -2868,7 +2868,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
} }
if (!Overloadable) if (!Overloadable)
S.Diag(FTI.getEllipsisLoc(), diag::err_ellipsis_first_arg); S.Diag(FTI.getEllipsisLoc(), diag::err_ellipsis_first_param);
} }
if (FTI.NumParams && FTI.Params[0].Param == 0) { if (FTI.NumParams && FTI.Params[0].Param == 0) {
@ -2891,10 +2891,10 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
: FTI.RefQualifierIsLValueRef? RQ_LValue : FTI.RefQualifierIsLValueRef? RQ_LValue
: RQ_RValue; : RQ_RValue;
// Otherwise, we have a function with an argument list that is // Otherwise, we have a function with a parameter list that is
// potentially variadic. // potentially variadic.
SmallVector<QualType, 16> ArgTys; SmallVector<QualType, 16> ParamTys;
ArgTys.reserve(FTI.NumParams); ParamTys.reserve(FTI.NumParams);
SmallVector<bool, 16> ConsumedParameters; SmallVector<bool, 16> ConsumedParameters;
ConsumedParameters.reserve(FTI.NumParams); ConsumedParameters.reserve(FTI.NumParams);
@ -2902,40 +2902,40 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
for (unsigned i = 0, e = FTI.NumParams; i != e; ++i) { for (unsigned i = 0, e = FTI.NumParams; i != e; ++i) {
ParmVarDecl *Param = cast<ParmVarDecl>(FTI.Params[i].Param); ParmVarDecl *Param = cast<ParmVarDecl>(FTI.Params[i].Param);
QualType ArgTy = Param->getType(); QualType ParamTy = Param->getType();
assert(!ArgTy.isNull() && "Couldn't parse type?"); assert(!ParamTy.isNull() && "Couldn't parse type?");
// Look for 'void'. void is allowed only as a single argument to a // Look for 'void'. void is allowed only as a single parameter to a
// function with no other parameters (C99 6.7.5.3p10). We record // function with no other parameters (C99 6.7.5.3p10). We record
// int(void) as a FunctionProtoType with an empty argument list. // int(void) as a FunctionProtoType with an empty parameter list.
if (ArgTy->isVoidType()) { if (ParamTy->isVoidType()) {
// If this is something like 'float(int, void)', reject it. 'void' // If this is something like 'float(int, void)', reject it. 'void'
// is an incomplete type (C99 6.2.5p19) and function decls cannot // is an incomplete type (C99 6.2.5p19) and function decls cannot
// have arguments of incomplete type. // have parameters of incomplete type.
if (FTI.NumParams != 1 || FTI.isVariadic) { if (FTI.NumParams != 1 || FTI.isVariadic) {
S.Diag(DeclType.Loc, diag::err_void_only_param); S.Diag(DeclType.Loc, diag::err_void_only_param);
ArgTy = Context.IntTy; ParamTy = Context.IntTy;
Param->setType(ArgTy); Param->setType(ParamTy);
} else if (FTI.Params[i].Ident) { } else if (FTI.Params[i].Ident) {
// Reject, but continue to parse 'int(void abc)'. // Reject, but continue to parse 'int(void abc)'.
S.Diag(FTI.Params[i].IdentLoc, diag::err_param_with_void_type); S.Diag(FTI.Params[i].IdentLoc, diag::err_param_with_void_type);
ArgTy = Context.IntTy; ParamTy = Context.IntTy;
Param->setType(ArgTy); Param->setType(ParamTy);
} else { } else {
// Reject, but continue to parse 'float(const void)'. // Reject, but continue to parse 'float(const void)'.
if (ArgTy.hasQualifiers()) if (ParamTy.hasQualifiers())
S.Diag(DeclType.Loc, diag::err_void_param_qualified); S.Diag(DeclType.Loc, diag::err_void_param_qualified);
// Do not add 'void' to the ArgTys list. // Do not add 'void' to the list.
break; break;
} }
} else if (ArgTy->isHalfType()) { } else if (ParamTy->isHalfType()) {
// Disallow half FP arguments. // Disallow half FP parameters.
// FIXME: This really should be in BuildFunctionType. // FIXME: This really should be in BuildFunctionType.
if (S.getLangOpts().OpenCL) { if (S.getLangOpts().OpenCL) {
if (!S.getOpenCLOptions().cl_khr_fp16) { if (!S.getOpenCLOptions().cl_khr_fp16) {
S.Diag(Param->getLocation(), S.Diag(Param->getLocation(),
diag::err_opencl_half_argument) << ArgTy; diag::err_opencl_half_param) << ParamTy;
D.setInvalidType(); D.setInvalidType();
Param->setInvalidDecl(); Param->setInvalidDecl();
} }
@ -2945,12 +2945,12 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
D.setInvalidType(); D.setInvalidType();
} }
} else if (!FTI.hasPrototype) { } else if (!FTI.hasPrototype) {
if (ArgTy->isPromotableIntegerType()) { if (ParamTy->isPromotableIntegerType()) {
ArgTy = Context.getPromotedIntegerType(ArgTy); ParamTy = Context.getPromotedIntegerType(ParamTy);
Param->setKNRPromoted(true); Param->setKNRPromoted(true);
} else if (const BuiltinType* BTy = ArgTy->getAs<BuiltinType>()) { } else if (const BuiltinType* BTy = ParamTy->getAs<BuiltinType>()) {
if (BTy->getKind() == BuiltinType::Float) { if (BTy->getKind() == BuiltinType::Float) {
ArgTy = Context.DoubleTy; ParamTy = Context.DoubleTy;
Param->setKNRPromoted(true); Param->setKNRPromoted(true);
} }
} }
@ -2962,7 +2962,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
HasAnyConsumedParameters |= Consumed; HasAnyConsumedParameters |= Consumed;
} }
ArgTys.push_back(ArgTy); ParamTys.push_back(ParamTy);
} }
if (HasAnyConsumedParameters) if (HasAnyConsumedParameters)
@ -2994,7 +2994,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
Exceptions, Exceptions,
EPI); EPI);
T = Context.getFunctionType(T, ArgTys, EPI); T = Context.getFunctionType(T, ParamTys, EPI);
} }
break; break;

View File

@ -46,3 +46,5 @@ void test2() { }
void test3(); void test3();
void test3; // expected-error {{incomplete type}} void test3; // expected-error {{incomplete type}}
void test3() { } void test3() { }
void ellipsis1(...); // expected-error {{ISO C requires a named parameter before '...'}}

View File

@ -3,7 +3,7 @@
#pragma OPENCL EXTENSION cl_khr_fp16 : disable #pragma OPENCL EXTENSION cl_khr_fp16 : disable
half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}} half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}}
half h) // expected-error{{declaring function argument of type 'half' is not allowed}} half h) // expected-error{{declaring function parameter of type 'half' is not allowed}}
{ {
half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}} half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}}
half b; // expected-error{{declaring variable of type 'half' is not allowed}} half b; // expected-error{{declaring variable of type 'half' is not allowed}}