]> granicus.if.org Git - clang/commitdiff
When Sema::ClassifyName() finds an invalid ivar reference, return an
authorDouglas Gregor <dgregor@apple.com>
Mon, 25 Apr 2011 15:05:41 +0000 (15:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 25 Apr 2011 15:05:41 +0000 (15:05 +0000)
invalid expression rather than the far-more-generic "error". Fixes a
mild regression in error recovery uncovered by the GCC testsuite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130128 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
lib/Sema/SemaDecl.cpp
test/SemaObjC/ivar-lookup.m

index 8a03864ad6a074874f708782309b92bf01eb1589..a324bdc0455154038c01c224625ea435a8ddec31 100644 (file)
@@ -148,7 +148,6 @@ Retry:
         break;     
           
       case Sema::NC_Type:
-        // We have a type.
         // We have a type. In C, this means that we have a declaration.
         if (!getLang().CPlusPlus) {
           ParsedType Type = Classification.getType();
index 05a077b38fcb3113b2b0b9d0a049570f625e12c5..d07bd4b72d39aedf70e9afe7c9105a09638d4d25 100644 (file)
@@ -411,11 +411,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S,
   // unqualified lookup mechanism.
   if (!SS.isSet() && CurMethod && !isResultTypeOrTemplate(Result, NextToken)) {
     ExprResult E = LookupInObjCMethod(Result, S, Name, true);
-
-    if (E.isInvalid())
-      return NameClassification::Error();
-    
-    if (E.get())
+    if (E.get() || E.isInvalid())
       return E;
     
     // Synthesize ivars lazily.
@@ -430,12 +426,8 @@ Sema::NameClassification Sema::ClassifyName(Scope *S,
 
         // FIXME: This is strange. Shouldn't we just take the ivar returned
         // from SynthesizeProvisionalIvar and continue with that?
-        E = LookupInObjCMethod(Result, S, Name, true);
-        
-        if (E.isInvalid())
-          return NameClassification::Error();
-        
-        if (E.get())
+        E = LookupInObjCMethod(Result, S, Name, true);   
+        if (E.get() || E.isInvalid())
           return E;
       }
     }
index 06e47116f73ca23ad8c733f707fedfd7504b9109..2b14bff85d841e72f3efe891846cb73215fc03e6 100644 (file)
@@ -35,3 +35,15 @@ extern struct foo x;
 }
 @end
 
+@interface TwoIvars {
+  int a;
+  int b;
+}
+@end
+
+@implementation TwoIvars
++ (int)classMethod {
+  return a + b; // expected-error{{instance variable 'a' accessed in class method}} \
+  // expected-error{{instance variable 'b' accessed in class method}}
+}
+@end