[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17

Balaji Iyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 11:56:57 PDT 2018


bviyer updated this revision to Diff 157730.
bviyer added a comment.

Fixed the comment as you suggested.

I do not have check in rights yet. Can you please check it in for me?


Repository:
  rC Clang

https://reviews.llvm.org/D49766

Files:
  include/clang/AST/TemplateBase.h
  test/SemaObjCXX/class-templ-error-null-init.mm


Index: test/SemaObjCXX/class-templ-error-null-init.mm
===================================================================
--- /dev/null
+++ 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);
Index: include/clang/AST/TemplateBase.h
===================================================================
--- include/clang/AST/TemplateBase.h
+++ 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, 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49766.157730.patch
Type: text/x-patch
Size: 1166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180727/c7bc9dcf/attachment.bin>


More information about the cfe-commits mailing list