[PATCH] D51853: Merge two attribute diagnostics into one
Andrew Savonichev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 04:25:39 PDT 2018
asavonic created this revision.
asavonic added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.
Merged the recently added `err_attribute_argument_negative` diagnostic
with existing `err_attribute_requires_positive_integer` diagnostic:
the former allows only strictly positive integer, while the latter
also allows zero.
Repository:
rC Clang
https://reviews.llvm.org/D51853
Files:
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaStmtAttr.cpp
test/SemaOpenCL/invalid-kernel-attrs.cl
Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===================================================================
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -38,8 +38,8 @@
kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
kernel __attribute__((intel_reqd_sub_group_size(8))) __attribute__((intel_reqd_sub_group_size(16))) void kernel16() {} //expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied with different parameters}}
-__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} //expected-error{{negative argument is not allowed for 'work_group_size_hint' attribute}}
-__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // expected-error{{negative argument is not allowed for 'reqd_work_group_size' attribute}}
+__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} //expected-error{{'work_group_size_hint' attribute requires a non-negative integral compile time constant expression}}
+__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // expected-error{{'reqd_work_group_size' attribute requires a non-negative integral compile time constant expression}}
// 4294967294 is a negative integer if treated as signed.
// Should compile successfully, since we expect an unsigned.
Index: lib/Sema/SemaStmtAttr.cpp
===================================================================
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -304,7 +304,7 @@
if (Val <= 0) {
S.Diag(A.getRange().getBegin(),
diag::err_attribute_requires_positive_integer)
- << A;
+ << A << /* positive */ 0;
return nullptr;
}
UnrollFactor = Val;
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -254,7 +254,8 @@
}
if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
- S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;
+ S.Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
+ << AI << /*non-negative*/ 1;
return false;
}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2497,7 +2497,8 @@
def err_attribute_bad_neon_vector_size : Error<
"Neon vector size must be 64 or 128 bits">;
def err_attribute_requires_positive_integer : Error<
- "%0 attribute requires a positive integral compile time constant expression">;
+ "%0 attribute requires a %select{positive|non-negative}1 "
+ "integral compile time constant expression">;
def err_attribute_requires_opencl_version : Error<
"%0 attribute requires OpenCL version %1%select{| or above}2">;
def warn_unsupported_target_attribute
@@ -2530,8 +2531,6 @@
"constant|a string|an identifier}1">;
def err_attribute_argument_outof_range : Error<
"%0 attribute requires integer constant between %1 and %2 inclusive">;
-def err_attribute_argument_negative : Error<
- "negative argument is not allowed for %0 attribute">;
def err_init_priority_object_attr : Error<
"can only use 'init_priority' attribute on file-scope definitions "
"of objects of class type">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51853.164651.patch
Type: text/x-patch
Size: 3481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180910/9e343dca/attachment.bin>
More information about the cfe-commits
mailing list