r338338 - [Sema] Relax a failing assert in TemplateArgumentLoc
Erik Pilkington via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 30 17:18:30 PDT 2018
Author: epilk
Date: Mon Jul 30 17:18:30 2018
New Revision: 338338
URL: http://llvm.org/viewvc/llvm-project?rev=338338&view=rev
Log:
[Sema] Relax a failing assert in TemplateArgumentLoc
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
Added:
cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm
Modified:
cfe/trunk/include/clang/AST/TemplateBase.h
Modified: cfe/trunk/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=338338&r1=338337&r2=338338&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TemplateBase.h (original)
+++ cfe/trunk/include/clang/AST/TemplateBase.h Mon Jul 30 17:18:30 2018
@@ -465,7 +465,13 @@ public:
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,
Added: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm?rev=338338&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm (added)
+++ cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm Mon Jul 30 17:18:30 2018
@@ -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);
More information about the cfe-commits
mailing list