summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-12-22 18:48:34 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-12-22 18:48:34 +0000
commit48badd66aeed20d0a52412b87e5f6856493f4a3a (patch)
tree56988bb1482a77be2288044c3fc46f8da3dcd446
parente17f6215292a87ac449eae820cb7557f0812f57b (diff)
downloadbcm5719-llvm-48badd66aeed20d0a52412b87e5f6856493f4a3a.tar.gz
bcm5719-llvm-48badd66aeed20d0a52412b87e5f6856493f4a3a.zip
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. llvm-svn: 290353
-rw-r--r--clang/include/clang/Basic/Attr.td3
-rw-r--r--clang/test/Sema/alloc-size.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index f6a5e54b2b3..107a3bdffa6 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -782,8 +782,7 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
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];
diff --git a/clang/test/Sema/alloc-size.c b/clang/test/Sema/alloc-size.c
index 600ef6870e9..7004a5a7d7f 100644
--- a/clang/test/Sema/alloc-size.c
+++ b/clang/test/Sema/alloc-size.c
@@ -14,10 +14,12 @@ void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'
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}}
OpenPOWER on IntegriCloud