Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8909,6 +8909,8 @@ class Parser : public CodeCompletionHandler {
bool OuterMightBeMessageSend = false);

///@}

TemplateParameterLists *TemplateParamsFromAlias = nullptr;
};

} // end namespace clang
Expand Down
17 changes: 17 additions & 0 deletions clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,17 @@ Decl *Parser::ParseAliasDeclarationAfterDeclarator(
<< FixItHint::CreateRemoval(SourceRange(D.EllipsisLoc));

Decl *DeclFromDeclSpec = nullptr;

this->TemplateParamsFromAlias = TemplateInfo.TemplateParams;

TypeResult TypeAlias =
ParseTypeName(nullptr,
TemplateInfo.Kind != ParsedTemplateKind::NonTemplate ? DeclaratorContext::AliasTemplate
: DeclaratorContext::AliasDecl,
AS, &DeclFromDeclSpec, &Attrs);

this->TemplateParamsFromAlias = nullptr;

if (OwnedType)
*OwnedType = DeclFromDeclSpec;

Expand Down Expand Up @@ -2173,6 +2179,17 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
assert(Tok.is(tok::l_brace) ||
(getLangOpts().CPlusPlus && Tok.is(tok::colon)) ||
isClassCompatibleKeyword());

if (TemplateParamsFromAlias) {
for (const TemplateParameterList *TPL : *TemplateParamsFromAlias) {
for (NamedDecl *D : *TPL) {
D->setInvalidDecl(true);
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(D);
TTPD->setTypeForDecl(Actions.Context.IntTy.getTypePtr());
}
}
}

if (SkipBody.ShouldSkip)
SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
TagOrTempResult.get());
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ static ParsedType buildNamedType(Sema &S, const CXXScopeSpec *SS, QualType T,
case Type::ObjCTypeParam:
case Type::TemplateTypeParm:
return ParsedType::make(T);
default:
llvm_unreachable("Unexpected Type Class");
//default:
//llvm_unreachable("Unexpected Type Class");
}

if (!SS || SS->isEmpty())
Expand Down
13 changes: 13 additions & 0 deletions clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ concept atomicish = requires() {
};
atomicish<int> f(); // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}}
} // namespace GH138820

namespace GH91564 {
template <class T> using A = struct B { // expected-error {{'GH91564::B' cannot be defined in a type alias template}}
template <class> void f() requires (T()); // expected-error {{atomic constraint must be of type 'bool' (found 'int')}} expected-note {{explicit instantiation refers here}}
};
template void B::f<void>(); // expected-error {{explicit instantiation of undefined function template 'f'}}

template <class T> using C = struct D { // expected-error {{'GH91564::D' cannot be defined in a type alias template}}
using E = T;
};
template <class> void g() requires (D::E()); // expected-error {{atomic constraint must be of type 'bool' (found 'D::E' (aka 'int'))}} expected-note {{explicit instantiation refers here}}
template void g<void>(); // expected-error {{explicit instantiation of undefined function template 'g'}}
}