[clang] Use the location of the void parameters when complaining that only a single void parameter should be present.

Fixes PR46417.

Differential Revision: https://reviews.llvm.org/D84678

Reviewed By: aaron.ballman
This commit is contained in:
Jaydeep Chauhan 2020-07-31 20:22:22 +01:00 committed by Bruno Ricci
parent 938adf42e6
commit 38d3e75332
No known key found for this signature in database
GPG key ID: D58C906B2F684D92
2 changed files with 26 additions and 1 deletions

View file

@ -5114,7 +5114,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// is an incomplete type (C99 6.2.5p19) and function decls cannot
// have parameters of incomplete type.
if (FTI.NumParams != 1 || FTI.isVariadic) {
S.Diag(DeclType.Loc, diag::err_void_only_param);
S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
ParamTy = Context.IntTy;
Param->setType(ParamTy);
} else if (FTI.Params[i].Ident) {

View file

@ -0,0 +1,25 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
void fun(
void a, // expected-error{{'void' must be the first and only parameter if specified}}
double b,
int c,
void d, // expected-error{{'void' must be the first and only parameter if specified}}
int e,
void f) // expected-error{{'void' must be the first and only parameter if specified}}
{}
void foo(
int a,
void, // expected-error{{'void' must be the first and only parameter if specified}}
int b);
void bar(
void, // expected-error{{'void' must be the first and only parameter if specified}}
...);
struct S {
S(
void, // expected-error{{'void' must be the first and only parameter if specified}}
void); // expected-error{{'void' must be the first and only parameter if specified}}
};