aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-01-26 02:31:38 +0000
committerRichard Trieu <rtrieu@google.com>2013-01-26 02:31:38 +0000
commitdb55c04cb3384b192a418a840a9ba6321941fc0d (patch)
tree3af8076dcc2f4eabfb63f3f753675bbfa2a9cc07 /lib/Parse/ParseDecl.cpp
parent98bfbf5354b8b35fd3efd12932894d7452697226 (diff)
Give a more informative error message when the dot or arrow operator is used
on a type. Currently, it gives a generic "expected unqualified-id" error. The new error message is "cannot use (dot|arrow) operator on a type". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index cfe5d1b16a..6acb0b2eb8 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -4498,9 +4498,12 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
if (D.getContext() == Declarator::MemberContext)
Diag(Tok, diag::err_expected_member_name_or_semi)
<< D.getDeclSpec().getSourceRange();
- else if (getLangOpts().CPlusPlus)
- Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;
- else
+ else if (getLangOpts().CPlusPlus) {
+ if (Tok.is(tok::period) || Tok.is(tok::arrow))
+ Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
+ else
+ Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;
+ } else
Diag(Tok, diag::err_expected_ident_lparen);
D.SetIdentifier(0, Tok.getLocation());
D.setInvalidType(true);