[cfe-commits] r89251 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td lib/Parse/ParseExpr.cpp lib/Sema/SemaExprCXX.cpp test/Parser/cxx-parse-member-pointer-op.cpp test/SemaCXX/cxx-member-pointer-op.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 18 13:54:49 PST 2009
Author: fjahanian
Date: Wed Nov 18 15:54:48 2009
New Revision: 89251
URL: http://llvm.org/viewvc/llvm-project?rev=89251&view=rev
Log:
This patch fixes a bug in misdiagnosing correct
use of pointer to data member.
Added:
cfe/trunk/test/SemaCXX/cxx-member-pointer-op.cpp
Removed:
cfe/trunk/test/Parser/cxx-parse-member-pointer-op.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=89251&r1=89250&r2=89251&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Nov 18 15:54:48 2009
@@ -117,8 +117,6 @@
"expected ';' after static_assert">;
def err_expected_semi_for : Error<"expected ';' in 'for' statement specifier">;
def err_expected_colon_after : Error<"expected ':' after %0">;
-def err_pointer_to_member_type : Error<
- "invalid use of pointer to member type after %0">;
def err_label_end_of_compound_statement : Error<
"label at end of compound statement: expected statement">;
def err_expected_string_literal : Error<"expected string literal">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=89251&r1=89250&r2=89251&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 18 15:54:48 2009
@@ -979,6 +979,8 @@
"non-type template argument is not a pointer to member constant">;
def err_template_arg_extra_parens : Error<
"non-type template argument cannot be surrounded by parentheses">;
+def err_pointer_to_member_type : Error<
+ "invalid use of pointer to member type after %select{.*|->*}0">;
// C++ template specialization
def err_template_spec_unknown_kind : Error<
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=89251&r1=89250&r2=89251&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Nov 18 15:54:48 2009
@@ -341,17 +341,6 @@
ColonLoc = ConsumeToken();
}
- if ((OpToken.is(tok::periodstar) || OpToken.is(tok::arrowstar))
- && Tok.is(tok::identifier)) {
- CXXScopeSpec SS;
- if (Actions.getTypeName(*Tok.getIdentifierInfo(),
- Tok.getLocation(), CurScope, &SS)) {
- const char *Opc = OpToken.is(tok::periodstar) ? "'.*'" : "'->*'";
- Diag(OpToken, diag::err_pointer_to_member_type) << Opc;
- return ExprError();
- }
-
- }
// Parse another leaf here for the RHS of the operator.
// ParseCastExpression works here because all RHS expressions in C have it
// as a prefix, at least. However, in C++, an assignment-expression could
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=89251&r1=89250&r2=89251&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Nov 18 15:54:48 2009
@@ -1445,6 +1445,12 @@
}
}
+ if (isa<CXXZeroInitValueExpr>(rex)) {
+ // Diagnose use of pointer-to-member type which when used as
+ // the functional cast in a pointer-to-member expression.
+ Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
+ return QualType();
+ }
// C++ 5.5p2
// The result is an object or a function of the type specified by the
// second operand.
Removed: cfe/trunk/test/Parser/cxx-parse-member-pointer-op.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-parse-member-pointer-op.cpp?rev=89250&view=auto
==============================================================================
--- cfe/trunk/test/Parser/cxx-parse-member-pointer-op.cpp (original)
+++ cfe/trunk/test/Parser/cxx-parse-member-pointer-op.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: clang-cc -fsyntax-only -pedantic -verify %s
-
-struct C {};
-
-typedef void (C::*pmfc)();
-
-void g(pmfc) {
- C *c;
- c->*pmfc(); // expected-error {{invalid use of pointer to member type after '->*'}}
- C c1;
- c1.*pmfc(); // expected-error {{invalid use of pointer to member type after '.*'}}
-}
-
Added: cfe/trunk/test/SemaCXX/cxx-member-pointer-op.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx-member-pointer-op.cpp?rev=89251&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx-member-pointer-op.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx-member-pointer-op.cpp Wed Nov 18 15:54:48 2009
@@ -0,0 +1,19 @@
+// RUN: clang-cc -fsyntax-only -pedantic -verify %s
+
+struct C {
+ static int (C::* a);
+};
+
+typedef void (C::*pmfc)();
+
+void g(pmfc) {
+ C *c;
+ c->*pmfc(); // expected-error {{invalid use of pointer to member type after ->*}}
+ C c1;
+ c1.*pmfc(); // expected-error {{invalid use of pointer to member type after .*}}
+}
+
+int a(C* x) {
+ return x->*C::a;
+}
+
More information about the cfe-commits
mailing list