[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 04:57:28 PDT 2020


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaType.cpp:5112
             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;
----------------
Are you sure that all parameters will have a valid `IdentLoc`? I am worried about the common case where the `void` parameter is unnamed.


================
Comment at: clang/test/Sema/void-argument.cpp:9
+    void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
----------------
I'd like to see some additional testing:
```
void foo(
  int a,
  void,
  int b
);

void bar(
  void,
  ...
);

struct S {
  S(
    void,
    void
  );
};
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84678/new/

https://reviews.llvm.org/D84678



More information about the cfe-commits mailing list