[PATCH] D23684: Resolve ambiguity in a declaration if global nested name specifier is used
Serge Pavlov via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 18 11:41:24 PDT 2016
sepavloff created this revision.
sepavloff added reviewers: rsmith, doug.gregor.
sepavloff added a subscriber: cfe-commits.
If a declaration references a function from global namespace by its
qualified name and if that function return type is a class or enum, there
is possible ambiguity. The declaration:
```
friend A::B::C();
```
may be considered as a declaration of a function `::C()` that returns
`A::B`, or a function `::B::C()` that returns `A`.
With this change when the compiler sees 'A::B' while parsing decl-spec, it
tries to find `B` within 'A'. If it finds, 'A::B' is treated as a part of
qualified name. If it doesn't and the current declaration declares a
function, '::B' is assumed to be a part of declarator. For non-function
declarations 'B' can be searched for in the global namespace to improve
diagnostics.
This changes fixes https://llvm.org/bugs/show_bug.cgi?id=28422.
https://reviews.llvm.org/D23684
Files:
include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/Parse/ParseDecl.cpp
lib/Parse/ParseDeclCXX.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/Parser.cpp
lib/Parse/RAIIObjectsForParser.h
lib/Sema/SemaCXXScopeSpec.cpp
lib/Sema/TreeTransform.h
test/CXX/drs/dr1xx.cpp
test/CXX/drs/dr2xx.cpp
test/Parser/cxx-decl.cpp
test/SemaCXX/nested-name-spec2.cpp
test/SemaCXX/pr18284-crash-on-invalid.cpp
test/SemaCXX/typo-correction.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23684.68583.patch
Type: text/x-patch
Size: 33609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160818/f2e8460a/attachment-0001.bin>
More information about the cfe-commits
mailing list