aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--test/SemaCXX/unary-real-imag.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 815a962262..80b465230e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6796,7 +6796,7 @@ ExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
UnaryOperatorKind Opc,
Expr *Input) {
if (getLangOptions().CPlusPlus && Input->getType()->isOverloadableType() &&
- Opc != UO_Extension) {
+ UnaryOperator::getOverloadedOperator(Opc) != OO_None) {
// Find all of the overloaded operators visible from this
// point. We perform both an operator-name lookup from the local
// scope and an argument-dependent lookup based on the types of
diff --git a/test/SemaCXX/unary-real-imag.cpp b/test/SemaCXX/unary-real-imag.cpp
new file mode 100644
index 0000000000..91b63e37b9
--- /dev/null
+++ b/test/SemaCXX/unary-real-imag.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+int i = __real__ A(); // expected-error {{invalid type 'A' to __real operator}}
+int j = __imag__ A(); // expected-error {{invalid type 'A' to __imag operator}}
+