[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 30 16:20:45 PDT 2017
EricWF updated this revision to Diff 108845.
EricWF added a comment.
- Address issues in inline comments. The patch should be ready to go now :-)
https://reviews.llvm.org/D35297
Files:
lib/Sema/SemaLookup.cpp
test/SemaCXX/overloaded-operator.cpp
Index: test/SemaCXX/overloaded-operator.cpp
===================================================================
--- test/SemaCXX/overloaded-operator.cpp
+++ test/SemaCXX/overloaded-operator.cpp
@@ -531,3 +531,22 @@
b3 / 0; // expected-note {{in instantiation of}} expected-error {{invalid operands to}}
}
}
+
+
+namespace PR27027 {
+ template <class T> void operator+(T, T) = delete; // expected-note 4 {{candidate}}
+ template <class T> void operator+(T) = delete; // expected-note 4 {{candidate}}
+
+ struct A {} a_global;
+ void f() {
+ A a;
+ +a; // expected-error {{overload resolution selected deleted operator '+'}}
+ a + a; // expected-error {{overload resolution selected deleted operator '+'}}
+ bool operator+(A);
+ extern bool operator+(A, A);
+ +a; // OK
+ a + a;
+ }
+ bool test_global_1 = +a_global; // expected-error {{overload resolution selected deleted operator '+'}}
+ bool test_global_2 = a_global + a_global; // expected-error {{overload resolution selected deleted operator '+'}}
+}
Index: lib/Sema/SemaLookup.cpp
===================================================================
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -1031,7 +1031,8 @@
FindLocalExternScope(LookupResult &R)
: R(R), OldFindLocalExtern(R.getIdentifierNamespace() &
Decl::IDNS_LocalExtern) {
- R.setFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_Ordinary);
+ R.setFindLocalExtern(R.getIdentifierNamespace() &
+ (Decl::IDNS_Ordinary | Decl::IDNS_NonMemberOperator));
}
void restore() {
R.setFindLocalExtern(OldFindLocalExtern);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35297.108845.patch
Type: text/x-patch
Size: 1669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170730/1fb20ccc/attachment-0001.bin>
More information about the cfe-commits
mailing list