[libcxx-commits] [clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)
Krystian Stasiowski via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 31 08:42:02 PDT 2024
================
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult &PotentialTemplateName) {
Priority);
}
+bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) {
+ assert(Tok.is(tok::coloncolon));
+ Sema::DisableTypoCorrectionRAII DTC(Actions);
+ ColonProtectionRAIIObject ColonProtection(*this);
+
+ SourceLocation StartLoc = Tok.getLocation();
+ if (TryAnnotateTypeOrScopeToken())
+ return true;
+ if (Tok.isSimpleTypeSpecifier(getLangOpts()))
+ return false;
+ CXXScopeSpec SS;
+ ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHasErrors=*/false,
+ /*EnteringContext=*/false);
+ ExprResult Result = tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false);
----------------
sdkrystian wrote:
> Parsing the same expression twice could also be problematic in some cases -- for example, if it contains a lambda, we might assign it the wrong mangling number. Can we arrange things such that for a valid program, we only parse the expression once?
@zygoloid That already is the case:
```cpp
template<int I>
struct A
{
constexpr static int x = 0;
template<typename T>
using B = A;
};
template<typename T>
struct B
{
constexpr static int x = 0;
};
template<typename T>
void f(T t)
{
t.A<0>::template B<decltype([]() { })>::x; // ok, interpreted as '((t.A) < 0) > ::template B<decltype([]() { })>::x'
// lambda expression is only parsed once
t.A<0>::template C<decltype([]() { })>::x; // warning: use 'template' keyword to treat 'A' as a dependent template name
// lambda expression is parsed twice
}
```
https://github.com/llvm/llvm-project/pull/100425
More information about the libcxx-commits
mailing list