]> granicus.if.org Git - clang/commitdiff
Types appearing more than once in a spec shouldn't matter.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 11 Oct 2009 09:11:23 +0000 (09:11 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 11 Oct 2009 09:11:23 +0000 (09:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/exception-spec.cpp

index 8720d81d6e7e055034537d67611fd7e13da5036a..4171ecea8a1b74375e0f315a3459c0616bfcdebe 100644 (file)
@@ -117,16 +117,21 @@ bool Sema::CheckEquivalentExceptionSpec(
   bool Success = true;
   // Both have a definite exception spec. Collect the first set, then compare
   // to the second.
-  llvm::SmallPtrSet<const Type*, 8> Types;
+  llvm::SmallPtrSet<const Type*, 8> OldTypes, NewTypes;
   for (FunctionProtoType::exception_iterator I = Old->exception_begin(),
        E = Old->exception_end(); I != E; ++I)
-    Types.insert(Context.getCanonicalType(*I).getTypePtr());
+    OldTypes.insert(Context.getCanonicalType(*I).getTypePtr());
 
   for (FunctionProtoType::exception_iterator I = New->exception_begin(),
-       E = New->exception_end(); I != E && Success; ++I)
-    Success = Types.erase(Context.getCanonicalType(*I).getTypePtr());
+       E = New->exception_end(); I != E && Success; ++I) {
+    const Type *TypePtr = Context.getCanonicalType(*I).getTypePtr();
+    if(OldTypes.count(TypePtr))
+      NewTypes.insert(TypePtr);
+    else
+      Success = false;
+  }
 
-  Success = Success && Types.empty();
+  Success = Success && OldTypes.size() == NewTypes.size();
 
   if (Success) {
     return false;
index cf7089cc7cc0182c58d929199450b74cb12f686c..bd22bf3ddd9e3c757590ba234fb11f0a886ef975 100644 (file)
@@ -62,6 +62,10 @@ void r7() throw(float); // expected-error {{exception specification in declarati
 void r8() throw(int);
 void r8() throw(const int);
 
+// Multiple appearances don't matter.
+void r9() throw(int, int);
+void r9() throw(int, int);
+
 struct A
 {
 };