consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104022
91177308-0d34-0410-b5e6-
96231b3b80d8
bool HasTrailingLParen,
bool IsAddressOfOperand);
- bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R);
+ bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
+ CorrectTypoContext CTC = CTC_Unknown);
OwningExprResult LookupInObjCMethod(LookupResult &R,
Scope *S,
///
/// \return false if new lookup candidates were found
bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS,
- LookupResult &R) {
+ LookupResult &R, CorrectTypoContext CTC) {
DeclarationName Name = R.getLookupName();
unsigned diagnostic = diag::err_undeclared_var_use;
// We didn't find anything, so try to correct for a typo.
DeclarationName Corrected;
- if (S && (Corrected = CorrectTypo(R, S, &SS))) {
+ if (S && (Corrected = CorrectTypo(R, S, &SS, false, CTC))) {
if (!R.empty()) {
if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) {
if (SS.isEmpty())
// If this name wasn't predeclared and if this is not a function
// call, diagnose the problem.
if (R.empty()) {
- if (DiagnoseEmptyLookup(S, SS, R))
+ if (DiagnoseEmptyLookup(S, SS, R, CTC_Unknown))
return ExprError();
assert(!R.empty() &&
WantExpressionKeywords = true;
WantCXXNamedCasts = true;
WantRemainingKeywords = true;
+
+ if (ObjCMethodDecl *Method = getCurMethodDecl())
+ if (Method->getClassInterface() &&
+ Method->getClassInterface()->getSuperClass())
+ Consumer.addKeywordResult(Context, "super");
+
break;
case CTC_NoKeywords:
LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
Sema::LookupOrdinaryName);
- if (SemaRef.DiagnoseEmptyLookup(S, SS, R))
+ if (SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression))
return Destroy(SemaRef, Fn, Args, NumArgs);
assert(!R.empty() && "lookup results empty despite recovery");
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -DNON_FIXITS -verify %s
// RUN: %clang -E -P %s -o %t
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true
// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -pedantic -Werror %t
@interface NSString // expected-note{{'NSString' declared here}}
@interface Super
- (int)method; // expected-note{{using}}
+- (int)method2;
@end
@interface Sub : Super
@end
+#ifdef NON_FIXITS
+double *isupper(int);
+
+@interface Sub2 : Super
+- (int)method2;
+@end
+
+@implementation Sub2
+- (int)method2 {
+ return [supper method2]; // expected-error{{use of undeclared identifier 'supper'}}
+}
+@end
+#endif
+
@interface Ivar
@end