[cfe-dev] Warnings patch for gcc 4.2.x

Justin Handville uniheliodem at gmail.com
Sat Sep 15 15:34:06 PDT 2007


This patch fixes all of the warnings currently generated in trunk with
-Wall -Werror.

Mostly, this stubs out missing enums in switch statements.  Also, note
the fix for InvalidDecl below.

Index: include/clang/AST/Decl.h
===================================================================
--- include/clang/AST/Decl.h	(revision 41989)
+++ include/clang/AST/Decl.h	(working copy)
@@ -57,7 +57,7 @@
   Kind DeclKind   :  8;

   /// InvalidDecl - This indicates a semantic error occurred.
-  int InvalidDecl :  1;
+  unsigned int InvalidDecl :  1;

 protected:
   Decl(Kind DK) : DeclKind(DK), InvalidDecl(0) {
Index: AST/Decl.cpp
===================================================================
--- AST/Decl.cpp	(revision 41989)
+++ AST/Decl.cpp	(working copy)
@@ -105,6 +105,21 @@
     case ObjcInterface:
       nInterfaceDecls++;
       break;
+    case ObjcClass:
+      //FIXME add functionality here.
+      break;
+    case ObjcMethod:
+      //FIXME add functionality here.
+      break;
+    case ObjcProtoMethod:
+      //FIXME add functionality here.
+      break;
+    case ObjcProtocol:
+      //FIXME add functionality here.
+      break;
+    case ObjcIvar:
+      //FIXME add functionality here.
+      break;
   }
 }

Index: AST/ASTContext.cpp
===================================================================
--- AST/ASTContext.cpp	(revision 41989)
+++ AST/ASTContext.cpp	(working copy)
@@ -730,6 +730,9 @@
     }
   }
   assert(0 && "getFloatingTypeOfSizeWithinDomain(): illegal domain");
+  //an invalid return value, but the assert
+  //will ensure that this code is never reached.
+  return VoidTy;
 }

 /// compareFloatingType - Handles 3 different combos:
Index: CodeGen/CGExpr.cpp
===================================================================
--- CodeGen/CGExpr.cpp	(revision 41989)
+++ CodeGen/CGExpr.cpp	(working copy)
@@ -134,6 +134,9 @@
     return EmitLoadOfOCUElementLValue(LV, ExprType);

   assert(0 && "Bitfield ref not impl!");
+  //an invalid RValue, but the assert will
+  //ensure that this point is never reached
+  return RValue();
 }

 // If this is a reference to a subset of the elements of a vector, either
@@ -270,6 +273,9 @@
     return LValue::MakeAddr(CGM.GetAddrOfGlobalDecl(D));
   }
   assert(0 && "Unimp declref");
+  //an invalid LValue, but the assert will
+  //ensure that this point is never reached.
+  return LValue();
 }

 LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
Index: CodeGen/CodeGenTypes.cpp
===================================================================
--- CodeGen/CodeGenTypes.cpp	(revision 41989)
+++ CodeGen/CodeGenTypes.cpp	(working copy)
@@ -136,6 +136,11 @@

     return llvm::FunctionType::get(ResultType, ArgTys, isVarArg, 0);
   }
+
+  case Type::ObjcInterface:
+    //FIXME: add missing functionality here
+    break;
+
   case Type::Tagged:
     const TagType &TT = cast<TagType>(Ty);
     const TagDecl *TD = TT.getDecl();



More information about the cfe-dev mailing list