On Jun 17, 2010, at 11:05 AM, Gabor Greif wrote: > On Thu, Jun 17, 2010 at 7:04 PM, John McCall <[email protected]> wrote: >> >> On Jun 17, 2010, at 4:29 AM, Gabor Greif wrote: >> >>> Author: ggreif >>> Date: Thu Jun 17 06:29:31 2010 >>> New Revision: 106216 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=106216&view=rev >>> Log: >>> fix some more gcc3.4 constness warnings >>> >>> Modified: >>> cfe/trunk/include/clang/AST/TypeLoc.h >>> cfe/trunk/include/clang/Lex/Token.h >>> cfe/trunk/lib/Sema/SemaExprCXX.cpp >>> >>> Modified: cfe/trunk/include/clang/AST/TypeLoc.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=106216&r1=106215&r2=106216&view=diff >>> ============================================================================== >>> --- cfe/trunk/include/clang/AST/TypeLoc.h (original) >>> +++ cfe/trunk/include/clang/AST/TypeLoc.h Thu Jun 17 06:29:31 2010 >>> @@ -142,7 +142,7 @@ >>> >>> /// \brief Return the TypeLoc for a type source info. >>> inline TypeLoc TypeSourceInfo::getTypeLoc() const { >>> - return TypeLoc(Ty, (void*)(this + 1)); >>> + return TypeLoc(Ty, const_cast<TypeSourceInfo*>(this + 1)); >>> } >> >> Please make this const_cast<void*>; right now it looks *really* bizarre. > > It does :-( > > I tried const_cast<void*> first but the compiler would not let me. > Probably because the const_cast is only allowed to strip cv-quals > and not let us up/downcast. > > This is all very strange, I believe gcc3.4's c-style cast typechecker > was programmed by crack smoking aliens... > > I can offer following alternatives: > > 1) extra line: > void *temp = const_cast<TypeSourceInfo*>(this + 1); > return TypeLoc(Ty, temp); > > 2) two casts in row: > return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
I think this would be fine. John. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
