r290353 - Make alloc_size only applicable to Functions.

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 22 10:48:35 PST 2016


Author: gbiv
Date: Thu Dec 22 12:48:34 2016
New Revision: 290353

URL: http://llvm.org/viewvc/llvm-project?rev=290353&view=rev
Log:
Make alloc_size only applicable to Functions.

I don't remember why I didn't make alloc_size only applicable to
Functions a year ago, but I can't see any compelling reason not to do
so now.

Fixes PR31453.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/test/Sema/alloc-size.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=290353&r1=290352&r2=290353&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Dec 22 12:48:34 2016
@@ -782,8 +782,7 @@ def EmptyBases : InheritableAttr, Target
 
 def AllocSize : InheritableAttr {
   let Spellings = [GCC<"alloc_size">];
-  let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
-                             "ExpectedFunctionWithProtoType">;
+  let Subjects = SubjectList<[Function]>;
   let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
   let TemplateDependent = 1;
   let Documentation = [AllocSizeDocs];

Modified: cfe/trunk/test/Sema/alloc-size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alloc-size.c?rev=290353&r1=290352&r2=290353&view=diff
==============================================================================
--- cfe/trunk/test/Sema/alloc-size.c (original)
+++ cfe/trunk/test/Sema/alloc-size.c Thu Dec 22 12:48:34 2016
@@ -14,10 +14,12 @@ void *fail8(int a, int b) __attribute__(
 
 int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}}
 
-int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K&R-style functions}}
+int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to functions}}
 
 void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}}
 
 void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
 void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}}
 void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}}
+
+int (*PR31453)(int) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to functions}}




More information about the cfe-commits mailing list