]> granicus.if.org Git - clang/commitdiff
Fix Cast Code
authorDavid Greene <greened@obbligato.org>
Tue, 15 Jan 2013 22:09:39 +0000 (22:09 +0000)
committerDavid Greene <greened@obbligato.org>
Tue, 15 Jan 2013 22:09:39 +0000 (22:09 +0000)
Eliminate a cast and resulting cast-qual warning by using a temporary
as the target of memcpy.

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

lib/Sema/DeclSpec.cpp

index a81c0093bb7b3e9b3eea132d07b5eef8aec3e877..fa63c2af38f2004aaa1215ae659065e75b04cc8a 100644 (file)
@@ -772,9 +772,10 @@ void DeclSpec::setProtocolQualifiers(Decl * const *Protos,
                                      SourceLocation *ProtoLocs,
                                      SourceLocation LAngleLoc) {
   if (NP == 0) return;
-  ProtocolQualifiers = new Decl*[NP];
+  Decl **ProtoQuals = new Decl*[NP];
+  memcpy(ProtoQuals, Protos, sizeof(Decl*)*NP);
+  ProtocolQualifiers = ProtoQuals;
   ProtocolLocs = new SourceLocation[NP];
-  memcpy((void*)ProtocolQualifiers, Protos, sizeof(Decl*)*NP);
   memcpy(ProtocolLocs, ProtoLocs, sizeof(SourceLocation)*NP);
   NumProtocolQualifiers = NP;
   ProtocolLAngleLoc = LAngleLoc;