[PATCH] D96043: Treat opencl_unroll_hint subject errors as semantic rather than parse errors
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 4 08:16:09 PST 2021
aaron.ballman created this revision.
aaron.ballman added a reviewer: Anastasia.
Herald added subscribers: zzheng, yaxunl.
aaron.ballman requested review of this revision.
Herald added a project: clang.
While working on a downstream project, I noticed some issues with the `opencl_unroll_hint` implementation. The attribute definition claimed the attribute was inheritable (which only applies to declaration attributes) and not a statement attribute. Further, it treats subject appertainment errors as being parse errors rather than semantic errors, which leads to us accepting invalid code. For instance, we currently fail to reject:
void foo() {
int i = 1000;
__attribute__((nomerge, opencl_unroll_hint(8)))
if (i) { foo(); }
}
This patch address the issues by clarifying that `opencl_unroll_hint` is a statement attribute and handling its appertainment checks in the semantic layer instead of the parsing layer. This changes the output of the diagnostic text to be more consistent with other appertainment errors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96043
Files:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/Parser/opencl-unroll-hint.cl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96043.321438.patch
Type: text/x-patch
Size: 5889 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210204/2c98d221/attachment.bin>
More information about the cfe-commits
mailing list