Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
77927cc3
Commit
77927cc3
authored
17 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
Add support for dispatching an objc message to a variable
in an initializer list. llvm-svn: 46367
parent
8917c5ac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
clang/Parse/ParseInit.cpp
+15
-2
15 additions, 2 deletions
clang/Parse/ParseInit.cpp
clang/Parse/ParseObjc.cpp
+1
-1
1 addition, 1 deletion
clang/Parse/ParseObjc.cpp
clang/test/Parser/objc-init.m
+6
-2
6 additions, 2 deletions
clang/test/Parser/objc-init.m
with
22 additions
and
5 deletions
clang/Parse/ParseInit.cpp
+
15
−
2
View file @
77927cc3
...
...
@@ -94,6 +94,8 @@ Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() {
// 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
())
{
// FIXME: Emit ext_gnu_missing_equal_designator for inits like
// [4][foo bar].
IdentifierInfo
*
Name
=
Tok
.
getIdentifierInfo
();
ConsumeToken
();
ExprResult
R
=
ParseObjCMessageExpressionBody
(
StartLoc
,
Name
,
0
);
...
...
@@ -101,14 +103,25 @@ Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() {
}
// Note that we parse this as an assignment expression, not a constant
// expression (allowing *=, =, etc)
. Sema needs to validate that the
// expression is a constant.
// expression (allowing *=, =, etc)
to handle the objc case. Sema needs
//
to validate that the
expression is a constant.
ExprResult
Idx
=
ParseAssignmentExpression
();
if
(
Idx
.
isInvalid
)
{
SkipUntil
(
tok
::
r_square
);
return
Idx
;
}
// Given an expression, we could either have a designator (if the next
// tokens are '...' or ']' or an objc message send. If this is an objc
// message send, handle it now.
if
(
getLang
().
ObjC1
&&
Tok
.
isNot
(
tok
::
ellipsis
)
&&
Tok
.
isNot
(
tok
::
r_square
))
{
// FIXME: Emit ext_gnu_missing_equal_designator for inits like
// [4][foo bar].
ExprResult
R
=
ParseObjCMessageExpressionBody
(
StartLoc
,
0
,
Idx
.
Val
);
return
ParsePostfixExpressionSuffix
(
R
);
}
// Handle the gnu array range extension.
if
(
Tok
.
is
(
tok
::
ellipsis
))
{
Diag
(
Tok
,
diag
::
ext_gnu_array_range
);
...
...
This diff is collapsed.
Click to expand it.
clang/Parse/ParseObjc.cpp
+
1
−
1
View file @
77927cc3
...
...
@@ -1276,7 +1276,7 @@ Parser::ExprResult Parser::ParseObjCMessageExpression() {
ExprResult
Res
=
ParseAssignmentExpression
();
if
(
Res
.
isInvalid
)
{
Diag
(
Tok
,
diag
::
err_invalid_receiver_to_message
);
SkipUntil
(
tok
::
identifier
);
SkipUntil
(
tok
::
r_square
);
return
Res
;
}
return
ParseObjCMessageExpressionBody
(
LBracLoc
,
0
,
Res
.
Val
);
...
...
This diff is collapsed.
Click to expand it.
clang/test/Parser/objc-init.m
+
6
−
2
View file @
77927cc3
...
...
@@ -3,11 +3,15 @@
@interface
NSNumber
;
-
()
METH
;
@end
int
main
()
{
void
test1
()
{
id
objects
[]
=
{[
NSNumber
METH
]};
}
void
test2
(
NSNumber
x
)
{
id
objects
[]
=
{[
x
METH
]};
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment