r360308 - [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose
Stephan Bergmann via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 09:16:00 PDT 2019
The below commit started to cause the following failure:
> $ cat test.cc
> template<typename> struct S1 { static int const n = 0; };
> template<int, typename> struct S2 { typedef int t; };
> template<typename T> struct S3 { typename S2<S1<T>::n < 0, int>::t n; };
>
> $ clang++ -fsyntax-only test.cc
> test.cc:3:53: error: use 'template' keyword to treat 'n' as a dependent
> template name
> template<typename T> struct S3 { typename S2<S1<T>::n < 0, int>::t n; };
> ^
> template
> test.cc:3:46: error: missing 'typename' prior to dependent type name
> 'S1<T>::S1<T>::n<0, int>::t'
> template<typename T> struct S3 { typename S2<S1<T>::n < 0, int>::t n; };
> ^~~~~~~~~~~~~~~~~~~~~
> typename
> test.cc:3:68: error: expected '>'
> template<typename T> struct S3 { typename S2<S1<T>::n < 0, int>::t n; };
> ^
> 3 errors generated.
On 09/05/2019 05:31, Richard Smith via cfe-commits wrote:
> Author: rsmith
> Date: Wed May 8 20:31:27 2019
> New Revision: 360308
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360308&view=rev
> Log:
> [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose
> template name is not visible to unqualified lookup.
>
> In order to support this without a severe degradation in our ability to
> diagnose typos in template names, this change significantly restructures
> the way we handle template-id-shaped syntax for which lookup of the
> template name finds nothing.
>
> Instead of eagerly diagnosing an undeclared template name, we now form a
> placeholder template-name representing a name that is known to not find
> any templates. When the parser sees such a name, it attempts to
> disambiguate whether we have a less-than comparison or a template-id.
> Any diagnostics or typo-correction for the name are delayed until its
> point of use.
>
> The upshot should be a small improvement of our diagostic quality
> overall: we now take more syntactic context into account when trying to
> resolve an undeclared identifier on the left hand side of a '<'. In
> fact, this works well enough that the backwards-compatible portion (for
> an undeclared identifier rather than a lookup that finds functions but
> no function templates) is enabled in all language modes.
>
> Added:
> cfe/trunk/test/SemaCXX/cxx2a-adl-only-template-id.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/DeclarationName.h
> cfe/trunk/include/clang/AST/TemplateName.h
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Basic/TemplateKinds.h
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/ODRHash.cpp
> cfe/trunk/lib/AST/TemplateName.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Parse/ParseExprCXX.cpp
> cfe/trunk/lib/Parse/ParseTemplate.cpp
> cfe/trunk/lib/Parse/ParseTentative.cpp
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
> cfe/trunk/test/CXX/drs/dr2xx.cpp
> cfe/trunk/test/CXX/drs/dr6xx.cpp
> cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
> cfe/trunk/test/FixIt/typo-crash.cpp
> cfe/trunk/test/Misc/diag-template-diffing.cpp
> cfe/trunk/test/Modules/module-private.cpp
> cfe/trunk/test/Modules/submodules-merge-defs.cpp
> cfe/trunk/test/Parser/cxx-ambig-init-templ.cpp
> cfe/trunk/test/Parser/cxx-template-argument.cpp
> cfe/trunk/test/Parser/cxx-template-decl.cpp
> cfe/trunk/test/SemaCXX/alias-template.cpp
> cfe/trunk/test/SemaCXX/class.cpp
> cfe/trunk/test/SemaCXX/destructor.cpp
> cfe/trunk/test/SemaCXX/invalid-member-expr.cpp
> cfe/trunk/test/SemaCXX/typo-correction.cpp
> cfe/trunk/test/SemaTemplate/dependent-base-classes.cpp
> cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp
> cfe/trunk/test/SemaTemplate/rdar9173693.cpp
> cfe/trunk/test/SemaTemplate/recovery-crash.cpp
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/www/cxx_status.html
More information about the cfe-commits
mailing list