]> granicus.if.org Git - clang/commitdiff
Allow the first parameter of operator new to be a cv-qualified
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 23:42:49 +0000 (23:42 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 23:42:49 +0000 (23:42 +0000)
size_t. Also, fix an issue with initialization of parameters in calls,
where we weren't removing the cv-qualifiers on the parameter type
itself. Fixes PR5823.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaInit.h
test/SemaCXX/new-delete.cpp

index 9e30af8f18789098ebe4cc0381f0b27be8c97602..ded89b453c9ded4140391a3d0c7920e353e96355 100644 (file)
@@ -4707,7 +4707,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
       << FnDecl->getDeclName() << ExpectedFirstParamType;
 
   // Check that the first parameter type is what we expect.
-  if (SemaRef.Context.getCanonicalType(FirstParamType) != 
+  if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() != 
       ExpectedFirstParamType)
     return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)
     << FnDecl->getDeclName() << ExpectedFirstParamType;
index dd3d2ea2ce4f2238a137446a735df88c67ed3ea6..45ee4fd64e72e18ddc878f855b25d46bda8a0fb1 100644 (file)
@@ -737,7 +737,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
       // FIXME: Do we need to check for default arguments here?
       FunctionDecl *Func = cast<FunctionDecl>(*Alloc);
       if (Func->getNumParams() == 1 &&
-          Context.getCanonicalType(Func->getParamDecl(0)->getType())==Argument)
+          Context.getCanonicalType(
+            Func->getParamDecl(0)->getType().getUnqualifiedType()) == Argument)
         return;
     }
   }
index 959c55e3d32d3b9cc077114c85311f61d43a3774..5eb819a6917652b4959a1fc92810a52f9e5cd862 100644 (file)
@@ -102,7 +102,7 @@ private:
   
   /// \brief Create the initialization entity for a parameter.
   InitializedEntity(ParmVarDecl *Parm)
-    : Kind(EK_Parameter), Parent(0), Type(Parm->getType()),
+    : Kind(EK_Parameter), Parent(0), Type(Parm->getType().getUnqualifiedType()),
       VariableOrMember(reinterpret_cast<DeclaratorDecl*>(Parm)) { }
   
   /// \brief Create the initialization entity for the result of a
index 91f800daea5274ee2982c3011783c656109a4c98..0e0f630bc497ff8fcc60f5e0a7792fb9c5517dc8 100644 (file)
@@ -18,7 +18,8 @@ struct V : U
 {
 };
 
-void* operator new(size_t); // expected-note 2 {{candidate}}
+// PR5823
+void* operator new(const size_t); // expected-note 2 {{candidate}}
 void* operator new(size_t, int*); // expected-note 3 {{candidate}}
 void* operator new(size_t, float*); // expected-note 3 {{candidate}}
 void* operator new(size_t, S); // expected-note 2 {{candidate}}
@@ -215,4 +216,3 @@ static void* f(void* g)
 {
     return new (g) X13();
 }
-