Just for fun, I tried compiling llvm/clang with gcc 4.5.1.  It gave me
a few interesting warnings, for which I have attached patches, that are
hopefully appropriate.  Please review and/or comment.
Fix for gcc 4.5.1 warning:

SemaExpr.cpp: In member function 'bool 
clang::Sema::DiagnoseEmptyLookup(clang::Scope*, clang::CXXScopeSpec&, 
clang::LookupResult&, clang::Sema::CorrectTypoContext)':
SemaExpr.cpp:944:58: warning: converting 'false' to pointer type for argument 4 
of 'clang::DeclarationName clang::Sema::CorrectTypo(clang::LookupResult&, 
clang::Scope*, clang::CXXScopeSpec*, clang::DeclContext*, bool, 
clang::Sema::CorrectTypoContext, const clang::ObjCObjectPointerType*)'

In this case, the declaration for CorrectTypo is:

  DeclarationName CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
                              DeclContext *MemberContext = 0,
                              bool EnteringContext = false,
                              CorrectTypoContext CTC = CTC_Unknown,
                              const ObjCObjectPointerType *OPT = 0);

so it looks like the MemberContext parameter was accidentally omitted.


Index: tools/clang/lib/Sema/SemaExpr.cpp
===================================================================
--- tools/clang/lib/Sema/SemaExpr.cpp   (revision 105267)
+++ tools/clang/lib/Sema/SemaExpr.cpp   (working copy)
@@ -941,7 +941,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeS
 
   // We didn't find anything, so try to correct for a typo.
   DeclarationName Corrected;
-  if (S && (Corrected = CorrectTypo(R, S, &SS, false, CTC))) {
+  if (S && (Corrected = CorrectTypo(R, S, &SS, 0, false, CTC))) {
     if (!R.empty()) {
       if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) 
{
         if (SS.isEmpty())
Fix for gcc 4.5.1 warning:

ParseExprCXX.cpp: In member function 'clang::Parser::OwningExprResult 
clang::Parser::ParseCXXAmbiguousParenExpression(clang::Parser::ParenParseOption&,
 clang::Parser::TypeTy*&, clang::SourceLocation, clang::SourceLocation&)':
ParseExprCXX.cpp:1854:54: warning: converting 'false' to pointer type for 
argument 4 of 'clang::Parser::OwningExprResult 
clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeTy*)'

This is trivial.


Index: tools/clang/lib/Parse/ParseExprCXX.cpp
===================================================================
--- tools/clang/lib/Parse/ParseExprCXX.cpp      (revision 105267)
+++ tools/clang/lib/Parse/ParseExprCXX.cpp      (working copy)
@@ -1851,7 +1851,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenPars
       // will be consumed.
       Result = ParseCastExpression(false/*isUnaryExpression*/,
                                    false/*isAddressofOperand*/,
-                                   NotCastExpr, false);
+                                   NotCastExpr, 0/*TypeOfCast*/);
     }
 
     // If we parsed a cast-expression, it's really a type-id, otherwise it's
Fix for gcc 4.5.1 warning:

PCHReader.cpp: In member function 'clang::SourceRange 
clang::PCHReader::ReadSourceRange(const clang::PCHReader::RecordData&, unsigned 
int&)':
PCHReader.cpp:2946:71: warning: operation on 'Idx' may be undefined

Here, gcc is right, since the order in which arguments to functions are
evaluated is undefined.  It looks like the assumption was left-to-right,
so make that explicit.


Index: tools/clang/lib/Frontend/PCHReader.cpp
===================================================================
--- tools/clang/lib/Frontend/PCHReader.cpp      (revision 105267)
+++ tools/clang/lib/Frontend/PCHReader.cpp      (working copy)
@@ -2942,8 +2942,9 @@ PCHReader::ReadNestedNameSpecifier(const RecordDat
 
 SourceRange
 PCHReader::ReadSourceRange(const RecordData &Record, unsigned &Idx) {
-  return SourceRange(SourceLocation::getFromRawEncoding(Record[Idx++]),
-                     SourceLocation::getFromRawEncoding(Record[Idx++]));
+  SourceLocation beg = SourceLocation::getFromRawEncoding(Record[Idx++]);
+  SourceLocation end = SourceLocation::getFromRawEncoding(Record[Idx++]);
+  return SourceRange(beg, end);
 }
 
 /// \brief Read an integral value
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to