summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-24 22:30:50 +0000
committerChris Lattner <sabre@nondot.org>2009-04-24 22:30:50 +0000
commitcd2a8c5864fa506ca3d98c720c936c4be3cc6a53 (patch)
treeecc3eff9d8129aa95e8231e3a096c81668d89664 /clang
parent9a1899ba428c131edff36380afb1bb45355c8ae6 (diff)
downloadbcm5719-llvm-cd2a8c5864fa506ca3d98c720c936c4be3cc6a53.tar.gz
bcm5719-llvm-cd2a8c5864fa506ca3d98c720c936c4be3cc6a53.zip
fix the sizeof error recovery issue (sizeof-interface.m:attributeRuns)
by correctly propagating the fact that the type was invalid up to the attributeRuns decl, then returning an ExprError when attributeRuns is formed (like we do for normal declrefexprs). llvm-svn: 69998
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp1
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp18
3 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 938e9655561..82684524308 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2579,6 +2579,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
// If there was an error parsing the assignment-expression, recover.
if (NumElements.isInvalid()) {
+ D.setInvalidType(true);
// If the expression was invalid, skip it.
SkipUntil(tok::r_square);
return;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 63b006277c0..e2f0ea4158b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3820,7 +3820,7 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
// example, unnamed unions inject all members into the struct namespace!
QualType T = GetTypeForDeclarator(D, S);
- bool InvalidDecl = false;
+ bool InvalidDecl = D.getInvalidType();
if (T.isNull()) {
InvalidDecl = true;
T = Context.IntTy;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 949c4ae6641..53fe80cb72a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -669,14 +669,14 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
LookupResult Lookup = LookupParsedName(S, SS, Name, LookupOrdinaryName,
false, true, Loc);
- NamedDecl *D = 0;
if (Lookup.isAmbiguous()) {
DiagnoseAmbiguousLookup(Lookup, Name, Loc,
SS && SS->isSet() ? SS->getRange()
: SourceRange());
return ExprError();
- } else
- D = Lookup.getAsDecl();
+ }
+
+ NamedDecl *D = Lookup.getAsDecl();
// If this reference is in an Objective-C method, then ivar lookup happens as
// well.
@@ -695,6 +695,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// Check if referencing a field with __attribute__((deprecated)).
if (DiagnoseUseOfDecl(IV, Loc))
return ExprError();
+
+ // If we're referencing an invalid decl, just return this as a silent
+ // error node. The error diagnostic was already emitted on the decl.
+ if (IV->isInvalidDecl())
+ return ExprError();
+
bool IsClsMethod = getCurMethodDecl()->isClassMethod();
// If a class method attemps to use a free standing ivar, this is
// an error.
@@ -726,7 +732,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
ClassDeclared)) {
if (IV->getAccessControl() != ObjCIvarDecl::Private ||
IFace == ClassDeclared)
- Diag(Loc, diag::warn_ivar_use_hidden)<<IV->getDeclName();
+ Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
}
}
// Needed to implement property "super.method" notation.
@@ -1253,8 +1259,8 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType,
// Reject sizeof(interface) and sizeof(interface<proto>) in 64-bit mode.
if (LangOpts.ObjCNonFragileABI && exprType->isObjCInterfaceType()) {
Diag(OpLoc, diag::err_sizeof_nonfragile_interface)
- << exprType << isSizeof;
- return false;
+ << exprType << isSizeof << ExprRange;
+ return true;
}
return false;
OpenPOWER on IntegriCloud