summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2010-09-05 23:15:52 +0000
committerEli Friedman <eli.friedman@gmail.com>2010-09-05 23:15:52 +0000
commit8ed2bac65d99d1ef37a11b8447337a824bc0175f (patch)
tree4e48f657385eda74a828bf47b66080d430e4a87a
parent7b7768a269d01983c7c3d881841cabbcf3200506 (diff)
downloadbcm5719-llvm-8ed2bac65d99d1ef37a11b8447337a824bc0175f.tar.gz
bcm5719-llvm-8ed2bac65d99d1ef37a11b8447337a824bc0175f.zip
PR8023: Don't crash on invalid uses of __real__ on class types in C++.
llvm-svn: 113124
-rw-r--r--clang/lib/Sema/SemaExpr.cpp2
-rw-r--r--clang/test/SemaCXX/unary-real-imag.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 815a9622628..80b465230e1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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/clang/test/SemaCXX/unary-real-imag.cpp b/clang/test/SemaCXX/unary-real-imag.cpp
new file mode 100644
index 00000000000..91b63e37b9a
--- /dev/null
+++ b/clang/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}}
+
OpenPOWER on IntegriCloud