Avoid superfluous errors regarding variable-length arrays (casts).

llvm-svn: 55759
This commit is contained in:
Daniel Dunbar 2008-09-04 03:43:08 +00:00
parent 8cde00a510
commit f2cf6d16e6
5 changed files with 23 additions and 9 deletions

View 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()));

View 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) {

View 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

View 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;

View 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,