diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4b9b722770f9..5d5e3849edc5 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -234,8 +234,8 @@ def ext_implicit_function_decl : ExtWarn< InGroup; def note_function_suggestion : Note<"did you mean %0?">; -def err_ellipsis_first_arg : Error< - "ISO C requires a named argument before '...'">; +def err_ellipsis_first_param : Error< + "ISO C requires a named parameter before '...'">; 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_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_half_declaration : Error< "declaring variable of type %0 is not allowed">; -def err_opencl_half_argument : Error< - "declaring function argument of type %0 is not allowed; did you forget * ?">; +def err_opencl_half_param : Error< + "declaring function parameter of type %0 is not allowed; did you forget * ?">; def err_opencl_half_return : Error< "declaring function return value of type %0 is not allowed; did you forget * ?">; def warn_enum_value_overflow : Warning<"overflow in enumeration value">; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 448c89071604..acacd213acba 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2868,7 +2868,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } 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) { @@ -2891,10 +2891,10 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, : FTI.RefQualifierIsLValueRef? RQ_LValue : 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. - SmallVector ArgTys; - ArgTys.reserve(FTI.NumParams); + SmallVector ParamTys; + ParamTys.reserve(FTI.NumParams); SmallVector ConsumedParameters; ConsumedParameters.reserve(FTI.NumParams); @@ -2902,40 +2902,40 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, for (unsigned i = 0, e = FTI.NumParams; i != e; ++i) { ParmVarDecl *Param = cast(FTI.Params[i].Param); - QualType ArgTy = Param->getType(); - assert(!ArgTy.isNull() && "Couldn't parse type?"); + QualType ParamTy = Param->getType(); + 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 - // int(void) as a FunctionProtoType with an empty argument list. - if (ArgTy->isVoidType()) { + // int(void) as a FunctionProtoType with an empty parameter list. + if (ParamTy->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. + // have parameters of incomplete type. if (FTI.NumParams != 1 || FTI.isVariadic) { S.Diag(DeclType.Loc, diag::err_void_only_param); - ArgTy = Context.IntTy; - Param->setType(ArgTy); + ParamTy = Context.IntTy; + Param->setType(ParamTy); } else if (FTI.Params[i].Ident) { // Reject, but continue to parse 'int(void abc)'. S.Diag(FTI.Params[i].IdentLoc, diag::err_param_with_void_type); - ArgTy = Context.IntTy; - Param->setType(ArgTy); + ParamTy = Context.IntTy; + Param->setType(ParamTy); } else { // Reject, but continue to parse 'float(const void)'. - if (ArgTy.hasQualifiers()) + if (ParamTy.hasQualifiers()) 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; } - } else if (ArgTy->isHalfType()) { - // Disallow half FP arguments. + } else if (ParamTy->isHalfType()) { + // Disallow half FP parameters. // FIXME: This really should be in BuildFunctionType. if (S.getLangOpts().OpenCL) { if (!S.getOpenCLOptions().cl_khr_fp16) { S.Diag(Param->getLocation(), - diag::err_opencl_half_argument) << ArgTy; + diag::err_opencl_half_param) << ParamTy; D.setInvalidType(); Param->setInvalidDecl(); } @@ -2945,12 +2945,12 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, D.setInvalidType(); } } else if (!FTI.hasPrototype) { - if (ArgTy->isPromotableIntegerType()) { - ArgTy = Context.getPromotedIntegerType(ArgTy); + if (ParamTy->isPromotableIntegerType()) { + ParamTy = Context.getPromotedIntegerType(ParamTy); Param->setKNRPromoted(true); - } else if (const BuiltinType* BTy = ArgTy->getAs()) { + } else if (const BuiltinType* BTy = ParamTy->getAs()) { if (BTy->getKind() == BuiltinType::Float) { - ArgTy = Context.DoubleTy; + ParamTy = Context.DoubleTy; Param->setKNRPromoted(true); } } @@ -2962,7 +2962,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, HasAnyConsumedParameters |= Consumed; } - ArgTys.push_back(ArgTy); + ParamTys.push_back(ParamTy); } if (HasAnyConsumedParameters) @@ -2994,7 +2994,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, Exceptions, EPI); - T = Context.getFunctionType(T, ArgTys, EPI); + T = Context.getFunctionType(T, ParamTys, EPI); } break; diff --git a/clang/test/Sema/invalid-decl.c b/clang/test/Sema/invalid-decl.c index 950d51deb4ce..f0954b01b98b 100644 --- a/clang/test/Sema/invalid-decl.c +++ b/clang/test/Sema/invalid-decl.c @@ -46,3 +46,5 @@ void test2() { } void test3(); void test3; // expected-error {{incomplete type}} void test3() { } + +void ellipsis1(...); // expected-error {{ISO C requires a named parameter before '...'}} diff --git a/clang/test/SemaOpenCL/half.cl b/clang/test/SemaOpenCL/half.cl index 0e6acb78c45c..11abf64633be 100644 --- a/clang/test/SemaOpenCL/half.cl +++ b/clang/test/SemaOpenCL/half.cl @@ -3,7 +3,7 @@ #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 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 b; // expected-error{{declaring variable of type 'half' is not allowed}}