[PATCH] D23684: Resolve ambiguity in a declaration if global nested name specifier is used

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 18 14:26:45 PDT 2016


PR28422 is invalid. Giving better diagnostics in this case seems
reasonable, but we should not accept the ill-formed code.

On 18 Aug 2016 11:41 a.m., "Serge Pavlov" <sepavloff at gmail.com> wrote:

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160818/e4baedd4/attachment.html>


More information about the cfe-commits mailing list