[cfe-commits] r130128 - in /cfe/trunk: lib/Parse/ParseStmt.cpp lib/Sema/SemaDecl.cpp test/SemaObjC/ivar-lookup.m
Douglas Gregor
dgregor at apple.com
Mon Apr 25 08:05:42 PDT 2011
Author: dgregor
Date: Mon Apr 25 10:05:41 2011
New Revision: 130128
URL: http://llvm.org/viewvc/llvm-project?rev=130128&view=rev
Log:
When Sema::ClassifyName() finds an invalid ivar reference, return an
invalid expression rather than the far-more-generic "error". Fixes a
mild regression in error recovery uncovered by the GCC testsuite.
Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/ivar-lookup.m
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=130128&r1=130127&r2=130128&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Apr 25 10:05:41 2011
@@ -148,7 +148,6 @@
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();
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=130128&r1=130127&r2=130128&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 25 10:05:41 2011
@@ -411,11 +411,7 @@
// 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 @@
// 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;
}
}
Modified: cfe/trunk/test/SemaObjC/ivar-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ivar-lookup.m?rev=130128&r1=130127&r2=130128&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/ivar-lookup.m (original)
+++ cfe/trunk/test/SemaObjC/ivar-lookup.m Mon Apr 25 10:05:41 2011
@@ -35,3 +35,15 @@
}
@end
+ at interface TwoIvars {
+ int a;
+ int b;
+}
+ at end
+
+ at 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}}
+}
+ at end
More information about the cfe-commits
mailing list