[PATCH] D84678: [clang] False line number in a function definition with "void" parameter
Jaydeep Chauhan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 09:55:23 PDT 2020
Jac1494 updated this revision to Diff 281644.
Jac1494 added a comment.
Address @aaron.ballman review comments.
I have added your test case that is passing as well.
This patch covers this scenario also.
Thanks @aaron.ballman
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84678/new/
https://reviews.llvm.org/D84678
Files:
clang/lib/Sema/SemaType.cpp
clang/test/Sema/void-argument.cpp
clang/test/Sema/void-unnamed.cpp
Index: clang/test/Sema/void-unnamed.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/void-unnamed.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+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}}
+};
Index: clang/test/Sema/void-argument.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void foo(
+ 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}}
+{}
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
// 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84678.281644.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200729/3359da88/attachment.bin>
More information about the cfe-commits
mailing list