Parsing, ASTs, and semantic analysis for the declaration of overloaded
operators in C++. Overloaded operators can be called directly via
their operator-function-ids, e.g., "operator+(foo, bar)", but we don't
yet implement the semantics of operator overloading to handle, e.g.,
"foo + bar".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58817 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index e1fbb6d..0b30631 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1305,6 +1305,15 @@
if (TypeTy *Type = ParseClassName())
D.SetDestructor(Type, II, TildeLoc);
+ } else if (Tok.is(tok::kw_operator)) {
+ SourceLocation OperatorLoc = Tok.getLocation();
+
+ // First try the name of an overloaded operator
+ if (IdentifierInfo *II = MaybeParseOperatorFunctionId()) {
+ D.SetIdentifier(II, OperatorLoc);
+ } else {
+ // This must be a user-defined conversion.
+ }
} else if (Tok.is(tok::l_paren)) {
// direct-declarator: '(' declarator ')'
// direct-declarator: '(' attributes declarator ')'