]> granicus.if.org Git - clang/commitdiff
Avoid superfluous errors regarding variable-length arrays (casts).
authorDaniel Dunbar <daniel@zuster.org>
Thu, 4 Sep 2008 03:43:08 +0000 (03:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 4 Sep 2008 03:43:08 +0000 (03:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55759 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h

index 229b05f93e013363554bccc812361748b618ca3e..88b8c9edefd50b12ec77eba53ff5647a2c4bddfb 100644 (file)
@@ -516,7 +516,7 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
     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()));
index 09f314077319cc88ca54c89b02a3511b32fa3621..ce0d7d8f8987dce6d634ec9771758c02913f85e5 100644 (file)
@@ -192,8 +192,9 @@ const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
 
 /// 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) {
index 853f44538412bc0fae4500eab7c92c93013aa5f2..b3881538361250afe22a5cc1718537592ee1805f 100644 (file)
@@ -151,7 +151,8 @@ public:
   
   /// 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
index 5b784aada3f0ab633da70767e1ddf21419ec7c75..87f5c24b82417ceef4c22aadb875e02cdd5cd784 100644 (file)
@@ -67,7 +67,10 @@ void CodeGenModule::Release() {
 
 /// 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 @@ void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type) {
 
 /// 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;
index b339ae9d67439f70d48ca53c4103c24642fc7eaa..70a91b6a9975d19d0184d866d99fcd3c346938ed 100644 (file)
@@ -194,12 +194,18 @@ public:
                                    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,