forked from OSchip/llvm-project
This patch fixes a bug in misdiagnosing correct
use of pointer to data member. llvm-svn: 89251
This commit is contained in:
parent
e9e9121f94
commit
1bc0f9affc
|
@ -117,8 +117,6 @@ def err_expected_semi_after_static_assert : Error<
|
|||
"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">;
|
||||
|
|
|
@ -979,6 +979,8 @@ def err_template_arg_not_pointer_to_member_form : Error<
|
|||
"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<
|
||||
|
|
|
@ -341,17 +341,6 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
|
|||
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
|
||||
|
|
|
@ -1445,6 +1445,12 @@ QualType Sema::CheckPointerToMemberOperands(
|
|||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
// RUN: clang-cc -fsyntax-only -pedantic -verify %s
|
||||
|
||||
struct C {};
|
||||
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->*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 '.*'}}
|
||||
c1.*pmfc(); // expected-error {{invalid use of pointer to member type after .*}}
|
||||
}
|
||||
|
||||
int a(C* x) {
|
||||
return x->*C::a;
|
||||
}
|
||||
|
Loading…
Reference in New Issue