[2/5] c++, openmp: Fix wrong error messages
Commit Message
Error messages wrongly said "invalid depend kind"
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_clause_proc_bind): Fix error message
(cp_parser_omp_clause_device_type): Likewise.
gcc/testsuite/ChangeLog:
* gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C: New test.
---
gcc/cp/parser.cc | 4 ++--
gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C
Comments
On Tue, Apr 07, 2026 at 07:08:23PM +0800, Yang Kun wrote:
> Error messages wrongly said "invalid depend kind"
>
> gcc/cp/ChangeLog:
> * parser.cc (cp_parser_omp_clause_proc_bind): Fix error message
> (cp_parser_omp_clause_device_type): Likewise.
>
> gcc/testsuite/ChangeLog:
> * gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C: New test.
> ---
> gcc/cp/parser.cc | 4 ++--
> gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C | 12 ++++++++++++
> 2 files changed, 14 insertions(+), 2 deletions(-)
> create mode 100644 gcc/testsuite/g++.dg/gomp/clause-errmsg-1.C
LGTM, but do you have FSF Copyright assignment on file or do you wish
to submit this under DCO?
See https://gcc.gnu.org/contribute.html#legal
If under DCO, then it needs to be reposted with a Signed-Off-By line.
Checked the C FE and it doesn't have this bug, and for device_type
it even has better diagnostics of
c_parser_error (parser, "expected %<host%>, %<nohost%> or %<any%>");
I guess we should for GCC 17 move to listing what are the valid kinds
unless the list is really long.
Jakub
> LGTM, but do you have FSF Copyright assignment on file or do you wish
> to submit this under DCO?
> See https://gcc.gnu.org/contribute.html#legal
> If under DCO, then it needs to be reposted with a Signed-Off-By line.
Okay, I've added the "Signed-off-by:" line. Is that okay now?
> Checked the C FE and it doesn't have this bug, and for device_type
> it even has better diagnostics of
> c_parser_error (parser, "expected %<host%>, %<nohost%> or %<any%>");
> I guess we should for GCC 17 move to listing what are the valid kinds
> unless the list is really long.
I've updated the error message for `device_type` to match the C front
end,
please have a review. Also, I thought this was a minor change that
didn't
require testing, so I removed it.
Additionally, I'm not sure how to reply to emails sent using `git
send-email`,
so I'm sending these patches as attachments.
On Wed, Apr 08, 2026 at 11:01:44AM +0200, yangkun wrote:
> > LGTM, but do you have FSF Copyright assignment on file or do you wish
> > to submit this under DCO?
> > See https://gcc.gnu.org/contribute.html#legal
> > If under DCO, then it needs to be reposted with a Signed-Off-By line.
> Okay, I've added the "Signed-off-by:" line. Is that okay now?
>
> > Checked the C FE and it doesn't have this bug, and for device_type
> > it even has better diagnostics of
> > c_parser_error (parser, "expected %<host%>, %<nohost%> or %<any%>");
> > I guess we should for GCC 17 move to listing what are the valid kinds
> > unless the list is really long.
> I've updated the error message for `device_type` to match the C front end,
> please have a review. Also, I thought this was a minor change that didn't
> require testing, so I removed it.
>
> Additionally, I'm not sure how to reply to emails sent using `git
> send-email`,
> so I'm sending these patches as attachments.
Thanks, approved and committed now.
Jakub
@@ -45815,7 +45815,7 @@ cp_parser_omp_clause_proc_bind (cp_parser *parser, tree list,
return c;
invalid_kind:
- cp_parser_error (parser, "invalid depend kind");
+ cp_parser_error (parser, "invalid proc_bind kind");
resync_fail:
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false,
@@ -45882,7 +45882,7 @@ cp_parser_omp_clause_device_type (cp_parser *parser, tree list,
return c;
invalid_kind:
- cp_parser_error (parser, "invalid depend kind");
+ cp_parser_error (parser, "invalid device_type kind");
resync_fail:
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false,
new file mode 100644
@@ -0,0 +1,12 @@
+// Verify that proc_bind and device_type clauses name the right clause
+// in their diagnostics, not "depend".
+// { dg-do compile }
+// { dg-additional-options "-fopenmp" }
+
+void f () {
+ #pragma omp parallel proc_bind(bad) // { dg-error "invalid proc_bind kind" }
+ ;
+}
+
+#pragma omp declare target device_type(bad) // { dg-error "invalid device_type kind" }
+void g() {}