<div dir="ltr">*cheers*<div><br></div><div>-eric</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 14, 2013 at 2:51 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently, "int->get();" or "int.get();" gives the vague error of "expected unqualified-id". The proposed error message is "cannot use arrow operator on a type" or "cannot use dot operator on a type".<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D297" target="_blank">http://llvm-reviews.chandlerc.com/D297</a><br>
<br>
Files:<br>
lib/Parse/ParseDecl.cpp<br>
test/Parser/cxx-decl.cpp<br>
include/clang/Basic/DiagnosticParseKinds.td<br>
<br>
Index: lib/Parse/ParseDecl.cpp<br>
===================================================================<br>
--- lib/Parse/ParseDecl.cpp<br>
+++ lib/Parse/ParseDecl.cpp<br>
@@ -4483,9 +4483,12 @@<br>
if (D.getContext() == Declarator::MemberContext)<br>
Diag(Tok, diag::err_expected_member_name_or_semi)<br>
<< D.getDeclSpec().getSourceRange();<br>
- else if (getLangOpts().CPlusPlus)<br>
- Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;<br>
- else<br>
+ else if (getLangOpts().CPlusPlus) {<br>
+ if (Tok.is(tok::period) || Tok.is(tok::arrow))<br>
+ Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);<br>
+ else<br>
+ Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;<br>
+ } else<br>
Diag(Tok, diag::err_expected_ident_lparen);<br>
D.SetIdentifier(0, Tok.getLocation());<br>
D.setInvalidType(true);<br>
Index: test/Parser/cxx-decl.cpp<br>
===================================================================<br>
--- test/Parser/cxx-decl.cpp<br>
+++ test/Parser/cxx-decl.cpp<br>
@@ -132,6 +132,24 @@<br>
typedef S() : n(1), m(2) { } // expected-error {{function definition declared 'typedef'}}<br>
};<br>
<br>
+struct DIE {<br>
+ void foo() {}<br>
+};<br>
+<br>
+void test (DIE die, DIE *Die, DIE INT, DIE *FLOAT) {<br>
+ DIE.foo(); // expected-error {{cannot use dot operator on a type}}<br>
+ die.foo();<br>
+<br>
+ DIE->foo(); // expected-error {{cannot use arrow operator on a type}}<br>
+ Die->foo();<br>
+<br>
+ int.foo(); // expected-error {{cannot use dot operator on a type}}<br>
+ INT.foo();<br>
+<br>
+ float->foo(); // expected-error {{cannot use arrow operator on a type}}<br>
+ FLOAT->foo();<br>
+}<br>
+<br>
// PR8380<br>
extern "" // expected-error {{unknown linkage language}}<br>
test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \<br>
Index: include/clang/Basic/DiagnosticParseKinds.td<br>
===================================================================<br>
--- include/clang/Basic/DiagnosticParseKinds.td<br>
+++ include/clang/Basic/DiagnosticParseKinds.td<br>
@@ -422,6 +422,8 @@<br>
def err_no_matching_param : Error<"parameter named %0 is missing">;<br>
<br>
/// C++ parser diagnostics<br>
+def err_invalid_operator_on_type : Error<<br>
+ "cannot use %select{dot|arrow}0 operator on a type">;<br>
def err_expected_unqualified_id : Error<<br>
"expected %select{identifier|unqualified-id}0">;<br>
def err_func_def_no_params : Error<<br>
</blockquote></div><br></div>