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
This commit is contained in:
@@ -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);
|
||||
// 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();
|
||||
|
||||
IdentifierInfo *Name = Tok.getIdentifierInfo();
|
||||
SourceLocation NameLoc = ConsumeToken();
|
||||
return ParseAssignmentExprWithObjCMessageExprStart(
|
||||
StartLoc, NameLoc, Name, ExprArg(Actions));
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user