Skip to content

Commit

Permalink
[Sema] Relax a failing assert in TemplateArgumentLoc
Browse files Browse the repository at this point in the history
Any of these template argument kinds can be represented with an expression, so
accept them in this constructor.

Patch by Balaji Iyer!

rdar://41459965

Differential revision: https://reviews.llvm.org/D49766

llvm-svn: 338338
  • Loading branch information
epilk committed Jul 31, 2018
1 parent 1e8c164 commit ca019e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clang/include/clang/AST/TemplateBase.h
Expand Up @@ -465,7 +465,13 @@ class TemplateArgumentLoc {

TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
: Argument(Argument), LocInfo(E) {
assert(Argument.getKind() == TemplateArgument::Expression);

// Permit any kind of template argument that can be represented with an
// expression
assert(Argument.getKind() == TemplateArgument::NullPtr ||
Argument.getKind() == TemplateArgument::Integral ||
Argument.getKind() == TemplateArgument::Declaration ||
Argument.getKind() == TemplateArgument::Expression);
}

TemplateArgumentLoc(const TemplateArgument &Argument,
Expand Down
7 changes: 7 additions & 0 deletions clang/test/SemaObjCXX/class-templ-error-null-init.mm
@@ -0,0 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
// expected-no-diagnostics
template <typename a, int* = nullptr>
struct e {
e(a) {}
};
e c(0);

0 comments on commit ca019e7

Please sign in to comment.