From 9f939f75c64770c746d78579f75a49f9c657e426 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 30 Jul 2013 14:10:17 +0000 Subject: [PATCH] Replacing err_attribute_argument_not_int with err_attribute_not_type_attr git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187419 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 -- lib/Sema/SemaDeclAttr.cpp | 25 +++++++++------- lib/Sema/SemaType.cpp | 33 ++++++++++++---------- lib/Sema/TargetAttributesSema.cpp | 5 ++-- test/Sema/address_spaces.c | 2 +- test/Sema/alloc_size.c | 2 +- test/Sema/attr-regparm.c | 2 +- test/Sema/neon-vector-types.c | 2 +- test/SemaCXX/init-priority-attr.cpp | 2 +- 9 files changed, 41 insertions(+), 34 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e31ac0a8ee..a8292a85e7 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1770,8 +1770,6 @@ def err_attribute_missing_parameter_name : Error< 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_argument_not_int : Error< - "'%0' attribute requires integer constant">; def err_aligned_attribute_argument_not_int : Error< "'aligned' attribute requires integer constant">; def err_alignas_attribute_wrong_decl_type : Error< diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index f14dcae836..d89365c208 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1174,8 +1174,9 @@ static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) { // check if the function argument is of an integer type QualType T = getFunctionOrMethodArgType(D, Idx).getNonReferenceType(); if (!T->isIntegerType()) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "alloc_size" << Ex->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << Ex->getSourceRange(); return; } SizeArgs.push_back(Idx); @@ -2691,8 +2692,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, llvm::APSInt ArgNum(32); if (E->isTypeDependent() || E->isValueDependent() || !E->isIntegerConstantExpr(ArgNum, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << Attr.getName()->getName() << E->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << E->getSourceRange(); return; } WGSize[i] = (unsigned) ArgNum.getZExtValue(); @@ -3047,8 +3049,9 @@ static void handleInitPriorityAttr(Sema &S, Decl *D, llvm::APSInt priority(32); if (priorityExpr->isTypeDependent() || priorityExpr->isValueDependent() || !priorityExpr->isIntegerConstantExpr(priority, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "init_priority" << priorityExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << priorityExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -3964,8 +3967,9 @@ static void handleOpenCLImageAccessAttr(Sema &S, Decl *D, const AttributeList &A llvm::APSInt ArgNum(32); if (E->isTypeDependent() || E->isValueDependent() || !E->isIntegerConstantExpr(ArgNum, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << Attr.getName()->getName() << E->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << E->getSourceRange(); return; } @@ -4070,8 +4074,9 @@ bool Sema::CheckRegparmAttr(const AttributeList &Attr, unsigned &numParams) { llvm::APSInt NumParams(32); if (NumParamsExpr->isTypeDependent() || NumParamsExpr->isValueDependent() || !NumParamsExpr->isIntegerConstantExpr(NumParams, Context)) { - Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "regparm" << NumParamsExpr->getSourceRange(); + Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << NumParamsExpr->getSourceRange(); Attr.setInvalid(); return true; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 6d35ad8d24..0106a679b9 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1630,8 +1630,9 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, if (!ArraySize->isTypeDependent() && !ArraySize->isValueDependent()) { llvm::APSInt vecSize(32); if (!ArraySize->isIntegerConstantExpr(vecSize, Context)) { - Diag(AttrLoc, diag::err_attribute_argument_not_int) - << "ext_vector_type" << ArraySize->getSourceRange(); + Diag(AttrLoc, diag::err_attribute_argument_type) + << "ext_vector_type" << AANT_ArgumentIntegerConstant + << ArraySize->getSourceRange(); return QualType(); } @@ -3847,8 +3848,9 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type, llvm::APSInt addrSpace(32); if (ASArgExpr->isTypeDependent() || ASArgExpr->isValueDependent() || !ASArgExpr->isIntegerConstantExpr(addrSpace, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << Attr.getName()->getName() << ASArgExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << ASArgExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -4480,8 +4482,9 @@ static void HandleOpenCLImageAccessAttribute(QualType& CurType, llvm::APSInt arg(32); if (sizeExpr->isTypeDependent() || sizeExpr->isValueDependent() || !sizeExpr->isIntegerConstantExpr(arg, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "opencl_image_access" << sizeExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << sizeExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -4521,8 +4524,9 @@ static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr, llvm::APSInt vecSize(32); if (sizeExpr->isTypeDependent() || sizeExpr->isValueDependent() || !sizeExpr->isIntegerConstantExpr(vecSize, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "vector_size" << sizeExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << sizeExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -4608,8 +4612,7 @@ static void HandleExtVectorTypeAttr(QualType &CurType, /// match one of the standard Neon vector types. static void HandleNeonVectorTypeAttr(QualType& CurType, const AttributeList &Attr, Sema &S, - VectorType::VectorKind VecKind, - const char *AttrName) { + VectorType::VectorKind VecKind) { // Check the attribute arguments. if (Attr.getNumArgs() != 1) { S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) @@ -4622,8 +4625,9 @@ static void HandleNeonVectorTypeAttr(QualType& CurType, llvm::APSInt numEltsInt(32); if (numEltsExpr->isTypeDependent() || numEltsExpr->isValueDependent() || !numEltsExpr->isIntegerConstantExpr(numEltsInt, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << AttrName << numEltsExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << numEltsExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -4739,13 +4743,12 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, break; case AttributeList::AT_NeonVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), - VectorType::NeonVector, "neon_vector_type"); + VectorType::NeonVector); attr.setUsedAsTypeAttr(); break; case AttributeList::AT_NeonPolyVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), - VectorType::NeonPolyVector, - "neon_polyvector_type"); + VectorType::NeonPolyVector); attr.setUsedAsTypeAttr(); break; case AttributeList::AT_OpenCLImageAccess: diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 499e613717..f84373944b 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -40,8 +40,9 @@ static void HandleMSP430InterruptAttr(Decl *d, Expr *NumParamsExpr = static_cast(Attr.getArg(0)); llvm::APSInt NumParams(32); if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int) - << "interrupt" << NumParamsExpr->getSourceRange(); + S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) + << Attr.getName() << AANT_ArgumentIntegerConstant + << NumParamsExpr->getSourceRange(); return; } diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index 69e0b2851d..4756af9d95 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -66,4 +66,4 @@ void access_as_field() } typedef int PR4997 __attribute__((address_space(Foobar))); // expected-error {{use of undeclared identifier 'Foobar'}} -__attribute__((address_space("12"))) int *i; // expected-error {{'address_space' attribute requires integer constant}} +__attribute__((address_space("12"))) int *i; // expected-error {{'address_space' attribute requires an integer constant}} diff --git a/test/Sema/alloc_size.c b/test/Sema/alloc_size.c index 2e9c30411e..053323a9f1 100644 --- a/test/Sema/alloc_size.c +++ b/test/Sema/alloc_size.c @@ -7,7 +7,7 @@ void* my_realloc(void*, unsigned) __attribute__((alloc_size(2))); void* fn1(int) __attribute__((alloc_size("xpto"))); // expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}} -void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{attribute requires integer constant}} +void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{'alloc_size' attribute requires an integer constant}} void* fn3(unsigned) __attribute__((alloc_size(0))); // expected-error{{attribute parameter 1 is out of bounds}} void* fn4(unsigned) __attribute__((alloc_size(2))); // expected-error{{attribute parameter 1 is out of bounds}} diff --git a/test/Sema/attr-regparm.c b/test/Sema/attr-regparm.c index d2833adb3c..d50dd113f7 100644 --- a/test/Sema/attr-regparm.c +++ b/test/Sema/attr-regparm.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s __attribute((regparm(2))) int x0(void); -__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires integer constant}} +__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires an integer constant}} __attribute((regparm(-1))) int x2(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} __attribute((regparm(5))) int x3(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} __attribute((regparm(5,3))) int x4(void); // expected-error{{'regparm' attribute takes one argument}} diff --git a/test/Sema/neon-vector-types.c b/test/Sema/neon-vector-types.c index 3dfbe1e5fb..d15a50d28f 100644 --- a/test/Sema/neon-vector-types.c +++ b/test/Sema/neon-vector-types.c @@ -19,7 +19,7 @@ typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t; typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{'neon_vector_type' attribute takes one argument}} // The number of elements must be an ICE. -typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires integer constant}} +typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{'neon_vector_type' attribute requires an integer constant}} // Only certain element types are allowed. typedef __attribute__((neon_vector_type(2))) double double_elt; // expected-error{{invalid vector element type}} diff --git a/test/SemaCXX/init-priority-attr.cpp b/test/SemaCXX/init-priority-attr.cpp index 1365953c2f..a91eb60ba9 100644 --- a/test/SemaCXX/init-priority-attr.cpp +++ b/test/SemaCXX/init-priority-attr.cpp @@ -23,7 +23,7 @@ Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_ Two coo[2] __attribute__((init_priority(3))); // expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}} -Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires integer constant}} +Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}} Two func() __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}} -- 2.40.0