]> granicus.if.org Git - clang/commitdiff
alloc_size attribute: there's nothing wrong with alloc_size(1,1). It just means the...
authorNuno Lopes <nunoplopes@sapo.pt>
Mon, 18 Jun 2012 16:27:56 +0000 (16:27 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Mon, 18 Jun 2012 16:27:56 +0000 (16:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158662 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/Sema/alloc_size.c

index e861892aba9b9b11fa74c2a85cba805cccd019b3..86c1f84668cc8a0e70e15bcdd0b515322767281b 100644 (file)
@@ -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<
index b8df752b38d411588845a70bf484337dc8209743..561b624167a7a17d6e3062bff7d69e9348c1d593 100644 (file)
@@ -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) {
index 18309e3106e1f69f7d0947fd500f9abd07da1fa8..ae3b4763ccdfafe757b25ecc6a80f5276a330010 100644 (file)
@@ -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}}