[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 30 17:18:54 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338338: [Sema] Relax a failing assert in TemplateArgumentLoc (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D49766?vs=157730&id=158138#toc
Repository:
rL LLVM
https://reviews.llvm.org/D49766
Files:
cfe/trunk/include/clang/AST/TemplateBase.h
cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm
Index: cfe/trunk/include/clang/AST/TemplateBase.h
===================================================================
--- cfe/trunk/include/clang/AST/TemplateBase.h
+++ cfe/trunk/include/clang/AST/TemplateBase.h
@@ -465,7 +465,13 @@
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,
Index: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm
===================================================================
--- cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm
+++ cfe/trunk/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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49766.158138.patch
Type: text/x-patch
Size: 1261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180731/627d8d87/attachment-0001.bin>
More information about the cfe-commits
mailing list