r195675 - Making type_tag_for_datatype consistent with its declared subject from Attr.td. Also updated the related testcase.
Aaron Ballman
aaron at aaronballman.com
Mon Nov 25 10:50:49 PST 2013
Author: aaronballman
Date: Mon Nov 25 12:50:49 2013
New Revision: 195675
URL: http://llvm.org/viewvc/llvm-project?rev=195675&view=rev
Log:
Making type_tag_for_datatype consistent with its declared subject from Attr.td. Also updated the related testcase.
Reviewed by Dmitri Gribenko.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/warn-type-safety.c
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195675&r1=195674&r2=195675&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Nov 25 12:50:49 2013
@@ -4089,6 +4089,12 @@ static void handleTypeTagForDatatypeAttr
if (!checkAttributeNumArgs(S, Attr, 1))
return;
+ if (!isa<VarDecl>(D)) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+ << Attr.getName() << ExpectedVariable;
+ return;
+ }
+
IdentifierInfo *PointerKind = Attr.getArgAsIdent(0)->Ident;
TypeSourceInfo *MatchingCTypeLoc = 0;
S.GetTypeFromParser(Attr.getMatchingCType(), &MatchingCTypeLoc);
Modified: cfe/trunk/test/Sema/warn-type-safety.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-type-safety.c?rev=195675&r1=195674&r2=195675&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-type-safety.c (original)
+++ cfe/trunk/test/Sema/warn-type-safety.c Mon Nov 25 12:50:49 2013
@@ -57,6 +57,8 @@ extern struct A datatype_wrong6
__attribute__(( type_tag_for_datatype(mpi,int,layout_compatible,not_a_flag) )); // expected-error {{invalid comparison flag 'not_a_flag'}}
+void datatype_wrong7(void) __attribute__((type_tag_for_datatype(datatype_wrong7, int))); // expected-error {{'type_tag_for_datatype' attribute only applies to variables}}
+
// Using a tag with kind A in a place where the function requires kind B should
// warn.
@@ -156,5 +158,3 @@ void test_64bit_magic(int *int_ptr, floa
F_func(float_ptr, 0xFFFFFFFFFFFFFFFFULL); // expected-warning {{argument type 'float *' doesn't match specified 'f' type tag that requires 'int *'}}
F_func(float_ptr, 0xFFFFFFFFULL);
}
-
-
More information about the cfe-commits
mailing list