diff options
author | Richard Trieu <rtrieu@google.com> | 2013-01-26 02:31:38 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2013-01-26 02:31:38 +0000 |
commit | db55c04cb3384b192a418a840a9ba6321941fc0d (patch) | |
tree | 3af8076dcc2f4eabfb63f3f753675bbfa2a9cc07 /lib/Parse/ParseDecl.cpp | |
parent | 98bfbf5354b8b35fd3efd12932894d7452697226 (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.cpp | 9 |
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); |