From: Daniel Dunbar Date: Thu, 4 Sep 2008 03:43:08 +0000 (+0000) Subject: Avoid superfluous errors regarding variable-length arrays (casts). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90df4b6661968a84bf64baee489bb2f6d948fcc1;p=clang Avoid superfluous errors regarding variable-length arrays (casts). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55759 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 229b05f93e..88b8c9edef 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -516,7 +516,7 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) { if (!(isa(V->getType()) && isa(cast(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())); diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 09f3140773..ce0d7d8f89 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -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) { diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 853f445384..b388153836 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -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 diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 5b784aada3..87f5c24b82 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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; diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index b339ae9d67..70a91b6a99 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -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,