aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp2
-rw-r--r--test/Sema/parentheses.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 31972bdd23..1faceb9425 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2045,7 +2045,7 @@ Expr *Expr::IgnoreParenImpCasts() {
Expr *Expr::IgnoreConversionOperator() {
if (CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(this)) {
- if (isa<CXXConversionDecl>(MCE->getMethodDecl()))
+ if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
return MCE->getImplicitObjectArgument();
}
return this;
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
index c14a671292..252455dcad 100644
--- a/test/Sema/parentheses.cpp
+++ b/test/Sema/parentheses.cpp
@@ -29,3 +29,17 @@ void f(Stream& s, bool b) {
// expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
// expected-note {{place parentheses around the '<<' expression to silence this warning}}
}
+
+struct S {
+ operator int() { return 42; }
+ friend S operator+(const S &lhs, bool) { return S(); }
+};
+
+void test(S *s, bool (S::*m_ptr)()) {
+ (void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '+' expression to silence this warning}}
+
+ // Don't crash on unusual member call expressions.
+ (void)((s->*m_ptr)() ? "foo" : "bar");
+}