diff options
| author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-06-18 16:27:56 +0000 |
|---|---|---|
| committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-06-18 16:27:56 +0000 |
| commit | e44e93aa6b82004c21843177f2f41b6281c492f0 (patch) | |
| tree | ce8a86fd7c85534f4d2d071aeaed2ce09e8b6c64 | |
| parent | a0e54d453b843c424a0558cc1478b80ea3f4ab2b (diff) | |
| download | bcm5719-llvm-e44e93aa6b82004c21843177f2f41b6281c492f0.tar.gz bcm5719-llvm-e44e93aa6b82004c21843177f2f41b6281c492f0.zip | |
alloc_size attribute: there's nothing wrong with alloc_size(1,1). It just means the function allocates x^2 bytes. GCC also accepts this syntax
llvm-svn: 158662
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 16 | ||||
| -rw-r--r-- | clang/test/Sema/alloc_size.c | 2 |
3 files changed, 3 insertions, 17 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e861892aba9..86c1f84668c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1509,8 +1509,6 @@ def err_attribute_argument_outof_range : Error< def err_init_priority_object_attr : Error< "can only use 'init_priority' attribute on file-scope definitions " "of objects of class type">; -def err_attribute_argument_duplicate: Error< - "'%0' attribute parameter %1 is duplicated">; def err_attribute_argument_n_not_int : Error< "'%0' attribute requires parameter %1 to be an integer constant">; def err_attribute_argument_n_not_string : Error< diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index b8df752b38d..561b624167a 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -972,15 +972,6 @@ static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) { return; } - // check if the argument is a duplicate - SmallVectorImpl<unsigned>::iterator Pos; - Pos = std::find(SizeArgs.begin(), SizeArgs.end(), x); - if (Pos != SizeArgs.end()) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_duplicate) - << "alloc_size" << I.getArgNum() << Ex->getSourceRange(); - return; - } - SizeArgs.push_back(x); } @@ -990,11 +981,8 @@ static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) { << "alloc_size" << 0 /*function*/<< 1 /*pointer*/ << D->getSourceRange(); } - unsigned size = SizeArgs.size(); - unsigned* start = &SizeArgs[0]; - llvm::array_pod_sort(start, start + size); - D->addAttr(::new (S.Context) AllocSizeAttr(Attr.getRange(), S.Context, start, - size)); + D->addAttr(::new (S.Context) AllocSizeAttr(Attr.getRange(), S.Context, + SizeArgs.data(), SizeArgs.size())); } static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) { diff --git a/clang/test/Sema/alloc_size.c b/clang/test/Sema/alloc_size.c index 18309e3106e..ae3b4763ccd 100644 --- a/clang/test/Sema/alloc_size.c +++ b/clang/test/Sema/alloc_size.c @@ -17,6 +17,6 @@ char fn6(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only app void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}} -void *fn8(int, int) __attribute__((alloc_size(1, 1))); // expected-error {{attribute parameter 2 is duplicated}} +void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}} |

