Merge two attribute diagnostics into one

Summary:
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.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51853

llvm-svn: 342367
This commit is contained in:
Andrew Savonichev 2018-09-17 10:39:46 +00:00
parent e29e40854b
commit 1a5623489b
4 changed files with 7 additions and 7 deletions

View File

@ -2498,7 +2498,8 @@ def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">;
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
@ -2531,8 +2532,6 @@ def err_attribute_argument_type : Error<
"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">;

View File

@ -254,7 +254,8 @@ static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
}
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;
}

View File

@ -304,7 +304,7 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A,
if (Val <= 0) {
S.Diag(A.getRange().getBegin(),
diag::err_attribute_requires_positive_integer)
<< A;
<< A << /* positive */ 0;
return nullptr;
}
UnrollFactor = Val;

View File

@ -38,8 +38,8 @@ __attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // expected-erro
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.