[cfe-commits] r101026 - in /cfe/trunk: lib/Parse/ParseInit.cpp lib/Parse/ParseObjc.cpp test/SemaObjC/super.m
Chris Lattner
sabre at nondot.org
Sun Apr 11 23:36:00 PDT 2010
Author: lattner
Date: Mon Apr 12 01:36:00 2010
New Revision: 101026
URL: http://llvm.org/viewvc/llvm-project?rev=101026&view=rev
Log:
fix a bug I noticed by inspection, correcting two reject-valid bugs.
Modified:
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/SemaObjC/super.m
Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=101026&r1=101025&r2=101026&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Mon Apr 12 01:36:00 2010
@@ -14,6 +14,7 @@
#include "clang/Parse/Designator.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/Scope.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
@@ -125,12 +126,16 @@
SourceLocation StartLoc = ConsumeBracket();
// If Objective-C is enabled and this is a typename (class message send) or
- // 'super', parse this as a message send expression.
+ // send to 'super', parse this as a message send expression.
if (getLang().ObjC1 && Tok.is(tok::identifier)) {
IdentifierInfo *II = Tok.getIdentifierInfo();
- if (II == Ident_super || Actions.getTypeName(*II, Tok.getLocation(),
- CurScope)) {
+ // Three cases. This is a message send to a type: [type foo]
+ // This is a message send to super: [super foo]
+ // This is a message sent to an expr: [super.bar foo]
+ if (Actions.getTypeName(*II, Tok.getLocation(), CurScope) ||
+ (II == Ident_super && GetLookAheadToken(1).isNot(tok::period) &&
+ CurScope->isInObjcMethodScope())) {
// If we have exactly one array designator, this used the GNU
// 'designation: array-designator' extension, otherwise there should be no
// designators at all!
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=101026&r1=101025&r2=101026&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Apr 12 01:36:00 2010
@@ -1723,7 +1723,6 @@
// If this is '[' 'super', then this is a magic superclass message.
// We parse '[' 'super' '.' 'foo' as an expression?
- // FIXME: Not in ParseInit.cpp?
if ((II == Ident_super && GetLookAheadToken(1).isNot(tok::period) &&
CurScope->isInObjcMethodScope()) ||
// Check to see if this is a typename. If so, it is a class message.
Modified: cfe/trunk/test/SemaObjC/super.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/super.m?rev=101026&r1=101025&r2=101026&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/super.m (original)
+++ cfe/trunk/test/SemaObjC/super.m Mon Apr 12 01:36:00 2010
@@ -6,6 +6,7 @@
@end
@interface A
++ superClassMethod;
@end
@interface B : A
@@ -21,6 +22,9 @@
+ classMethod {
[super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
+
+ id X[] = { [ super superClassMethod] };
+ id Y[] = { [ super.superClassMethod iMethod] };
return 0;
}
@end
@@ -63,5 +67,7 @@
id super = 0;
[(B*)super instanceMethod];
int *s1 = (int*)super;
+
+ id X[] = { [ super superClassMethod] };
return 0;
}
More information about the cfe-commits
mailing list