summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-11-07 00:02:45 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-11-07 00:02:45 +0000
commit01cad4c6b03579286dbed8900d9e16ea7eebea8c (patch)
tree3b1e3c2e7adf61059834df333a3e88fc9d498d5d
parent9eb7701dff9df1c7900a14c75eb1fba5cd48ed8a (diff)
downloadbcm5719-llvm-01cad4c6b03579286dbed8900d9e16ea7eebea8c.tar.gz
bcm5719-llvm-01cad4c6b03579286dbed8900d9e16ea7eebea8c.zip
Make sure isCopyAssignment is only true for actual copy assignment operators,
instead of all assignment operators. The mistake messes up IRGen because it ends up assuming that the assignment operator is actually the implicit copy assignment operator, and therefore tries to emit the RHS as an lvalue. llvm-svn: 86307
-rw-r--r--clang/lib/AST/DeclCXX.cpp3
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp1
-rw-r--r--clang/test/CodeGenCXX/assign-operator.cpp9
3 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index b4c0c59733e..e325a25c762 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -280,6 +280,9 @@ void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
return;
// This is a copy assignment operator.
+ // Note on the decl that it is a copy assignment operator.
+ OpDecl->setCopyAssignment(true);
+
// Suppress the implicit declaration of a copy constructor.
UserDeclaredCopyAssignment = true;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f3561bfa0f4..c7fd5ccd1e6 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -4183,7 +4183,6 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
assert(isa<CXXMethodDecl>(FnDecl) &&
"Overloaded = not member, but not filtered.");
CXXMethodDecl *Method = cast<CXXMethodDecl>(FnDecl);
- Method->setCopyAssignment(true);
Method->getParent()->addedAssignmentOperator(Context, Method);
}
diff --git a/clang/test/CodeGenCXX/assign-operator.cpp b/clang/test/CodeGenCXX/assign-operator.cpp
new file mode 100644
index 00000000000..3e0be451943
--- /dev/null
+++ b/clang/test/CodeGenCXX/assign-operator.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-cc %s -emit-llvm-only -verify
+
+class x {
+int operator=(int);
+};
+void a() {
+ x a;
+ a = 1u;
+}
OpenPOWER on IntegriCloud