summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseInit.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-11 08:28:14 +0000
committerChris Lattner <sabre@nondot.org>2010-04-11 08:28:14 +0000
commita36ec4243bea51afe39c9d25206fe26dd30d748c (patch)
tree2ecb63e698763bc8137a6defde656d1ba0f4fcaf /clang/lib/Parse/ParseInit.cpp
parent90c58faea6559a237ea26900a2494936b50eaa5a (diff)
downloadbcm5719-llvm-a36ec4243bea51afe39c9d25206fe26dd30d748c.tar.gz
bcm5719-llvm-a36ec4243bea51afe39c9d25206fe26dd30d748c.zip
fix PR6811 by not parsing 'super' as a magic expression in
LookupInObjCMethod. Doing so allows all sorts of invalid code to slip through to codegen. This patch does not change the AST representation of super, though that would now be a natural thing to do since it can only be in the receiver position and in the base of a ObjCPropertyRefExpr. There are still several ugly areas handling super in the parser, but this is definitely a step in the right direction. llvm-svn: 100959
Diffstat (limited to 'clang/lib/Parse/ParseInit.cpp')
-rw-r--r--clang/lib/Parse/ParseInit.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 9154d8d5998..57751c9c3fb 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -124,23 +124,27 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
//
SourceLocation StartLoc = ConsumeBracket();
- // If Objective-C is enabled and this is a typename or other identifier
- // receiver, parse this as a message send expression.
- if (getLang().ObjC1 && isTokObjCMessageIdentifierReceiver()) {
- // If we have exactly one array designator, this used the GNU
- // 'designation: array-designator' extension, otherwise there should be no
- // designators at all!
- if (Desig.getNumDesignators() == 1 &&
- (Desig.getDesignator(0).isArrayDesignator() ||
- Desig.getDesignator(0).isArrayRangeDesignator()))
- Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
- else if (Desig.getNumDesignators() > 0)
- Diag(Tok, diag::err_expected_equal_designator);
-
- IdentifierInfo *Name = Tok.getIdentifierInfo();
- SourceLocation NameLoc = ConsumeToken();
- return ParseAssignmentExprWithObjCMessageExprStart(
- StartLoc, NameLoc, Name, ExprArg(Actions));
+ // If Objective-C is enabled and this is a typename (class message send) or
+ // '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)) {
+ // If we have exactly one array designator, this used the GNU
+ // 'designation: array-designator' extension, otherwise there should be no
+ // designators at all!
+ if (Desig.getNumDesignators() == 1 &&
+ (Desig.getDesignator(0).isArrayDesignator() ||
+ Desig.getDesignator(0).isArrayRangeDesignator()))
+ Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
+ else if (Desig.getNumDesignators() > 0)
+ Diag(Tok, diag::err_expected_equal_designator);
+
+ SourceLocation NameLoc = ConsumeToken();
+ return ParseAssignmentExprWithObjCMessageExprStart(
+ StartLoc, NameLoc, II, ExprArg(Actions));
+ }
}
// Note that we parse this as an assignment expression, not a constant
OpenPOWER on IntegriCloud