[cfe-commits] r55759 - in /cfe/trunk/lib/CodeGen: CGExprScalar.cpp CodeGenFunction.cpp CodeGenFunction.h CodeGenModule.cpp CodeGenModule.h

Daniel Dunbar daniel at zuster.org
Wed Sep 3 20:43:10 PDT 2008


Author: ddunbar
Date: Wed Sep  3 22:43:08 2008
New Revision: 55759

URL: http://llvm.org/viewvc/llvm-project?rev=55759&view=rev
Log:
Avoid superfluous errors regarding variable-length arrays (casts).

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=55759&r1=55758&r2=55759&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Sep  3 22:43:08 2008
@@ -516,7 +516,7 @@
     if (!(isa<llvm::PointerType>(V->getType()) &&
           isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
                                ->getElementType()))) {
-      CGF.ErrorUnsupported(E, "variable-length array cast");
+      CGF.ErrorUnsupported(E, "variable-length array cast", true);
       if (E->getType()->isVoidType())
         return 0;
       return llvm::UndefValue::get(CGF.ConvertType(E->getType()));

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=55759&r1=55758&r2=55759&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Sep  3 22:43:08 2008
@@ -192,8 +192,9 @@
 
 /// ErrorUnsupported - Print out an error that codegen doesn't support the
 /// specified stmt yet.
-void CodeGenFunction::ErrorUnsupported(const Stmt *S, const char *Type) {
-  CGM.ErrorUnsupported(S, Type);
+void CodeGenFunction::ErrorUnsupported(const Stmt *S, const char *Type,
+                                       bool OmitOnError) {
+  CGM.ErrorUnsupported(S, Type, OmitOnError);
 }
 
 unsigned CodeGenFunction::GetIDForAddrOfLabel(const LabelStmt *L) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=55759&r1=55758&r2=55759&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Sep  3 22:43:08 2008
@@ -151,7 +151,8 @@
   
   /// ErrorUnsupported - Print out an error that codegen doesn't support the
   /// specified stmt yet.
-  void ErrorUnsupported(const Stmt *S, const char *Type);
+  void ErrorUnsupported(const Stmt *S, const char *Type,
+                        bool OmitOnError=false);
 
   //===--------------------------------------------------------------------===//
   //                                  Helpers

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=55759&r1=55758&r2=55759&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Sep  3 22:43:08 2008
@@ -67,7 +67,10 @@
 
 /// ErrorUnsupported - Print out an error that codegen doesn't support the
 /// specified stmt yet.
-void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type) {
+void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type,
+                                     bool OmitOnError) {
+  if (OmitOnError && getDiags().hasErrorOccurred())
+    return;
   unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error, 
                                                "cannot codegen this %0 yet");
   SourceRange Range = S->getSourceRange();
@@ -78,7 +81,10 @@
 
 /// ErrorUnsupported - Print out an error that codegen doesn't support the
 /// specified decl yet.
-void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type) {
+void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type,
+                                     bool OmitOnError) {
+  if (OmitOnError && getDiags().hasErrorOccurred())
+    return;
   unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error, 
                                                "cannot codegen this %0 yet");
   std::string Msg = Type;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=55759&r1=55758&r2=55759&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Sep  3 22:43:08 2008
@@ -194,12 +194,18 @@
                                    const AnnotateAttr *AA, unsigned LineNo);
     
   /// ErrorUnsupported - Print out an error that codegen doesn't support the
-  /// specified stmt yet.    
-  void ErrorUnsupported(const Stmt *S, const char *Type);
+  /// specified stmt yet.
+  /// \param OmitOnError - If true, then this error should only be
+  /// emitted if no other errors have been reported.
+  void ErrorUnsupported(const Stmt *S, const char *Type, 
+                        bool OmitOnError=false);
   
   /// ErrorUnsupported - Print out an error that codegen doesn't support the
   /// specified decl yet.
-  void ErrorUnsupported(const Decl *D, const char *Type);
+  /// \param OmitOnError - If true, then this error should only be
+  /// emitted if no other errors have been reported.
+  void ErrorUnsupported(const Decl *D, const char *Type,
+                        bool OmitOnError=false);
 
 private:
   void SetFunctionAttributes(const FunctionDecl *FD,





More information about the cfe-commits mailing list