[cfe-commits] r69998 - in /cfe/trunk/lib: Parse/ParseDecl.cpp Sema/SemaDecl.cpp Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Fri Apr 24 15:30:50 PDT 2009


Author: lattner
Date: Fri Apr 24 17:30:50 2009
New Revision: 69998

URL: http://llvm.org/viewvc/llvm-project?rev=69998&view=rev
Log:
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).

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=69998&r1=69997&r2=69998&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Apr 24 17:30:50 2009
@@ -2579,6 +2579,7 @@
   
   // 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;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69998&r1=69997&r2=69998&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr 24 17:30:50 2009
@@ -3820,7 +3820,7 @@
   // 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;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=69998&r1=69997&r2=69998&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Apr 24 17:30:50 2009
@@ -669,14 +669,14 @@
   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 @@
         // 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 @@
                                                            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 @@
   // 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;





More information about the cfe-commits mailing list