From f2cf6d16e6046233b05728a64119c69709e682ed Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 4 Sep 2008 03:43:08 +0000 Subject: [PATCH] Avoid superfluous errors regarding variable-length arrays (casts). llvm-svn: 55759 --- clang/lib/CodeGen/CGExprScalar.cpp | 2 +- clang/lib/CodeGen/CodeGenFunction.cpp | 5 +++-- clang/lib/CodeGen/CodeGenFunction.h | 3 ++- clang/lib/CodeGen/CodeGenModule.cpp | 10 ++++++++-- clang/lib/CodeGen/CodeGenModule.h | 12 +++++++++--- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 229b05f93e01..88b8c9edefd5 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/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/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 09f314077319..ce0d7d8f8987 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/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/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 853f44538412..b38815383612 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/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/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5b784aada3f0..87f5c24b8241 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index b339ae9d6743..70a91b6a9975 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/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,