[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-06 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Thank you for the review!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56271/new/

https://reviews.llvm.org/D56271



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-06 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350501: [SemaCXX] Fix ICE for unexpanded parameter pack 
(authored by modocache, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56271/new/

https://reviews.llvm.org/D56271

Files:
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/test/SemaCXX/alias-template.cpp


Index: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);
Index: cfe/trunk/test/SemaCXX/alias-template.cpp
===
--- cfe/trunk/test/SemaCXX/alias-template.cpp
+++ cfe/trunk/test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 
'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}


Index: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);
Index: cfe/trunk/test/SemaCXX/alias-template.cpp
===
--- cfe/trunk/test/SemaCXX/alias-template.cpp
+++ cfe/trunk/test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good, thank you!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56271/new/

https://reviews.llvm.org/D56271



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-03 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added a reviewer: rsmith.

The documentation for RecursiveASTVisitor::TraverseDecl states that the
Decl being traversed may be null. In fact, this is the case when a
CXXCatchStmt with no exception decl is traversed. Because the visitor
for diagnosing unexpanded parameter packs does not check for null, it
ends up crashing when it attempts to call the Decl::isParameterPack
method on a null Decl pointer.

Add a null check to prevent an ICE, and a test case that would crash
otherwise. Also, because the test requires C++ exceptions and C++14,
change the test parameters for the entire test file. (Alternatively, I
thought about adding a new test file, but went with this approach for my
own convenience.)

Co-authored-by: Andreas Molzer 
Co-authored-by: Mara Bos 


Repository:
  rC Clang

https://reviews.llvm.org/D56271

Files:
  lib/Sema/SemaTemplateVariadic.cpp
  test/SemaCXX/alias-template.cpp


Index: test/SemaCXX/alias-template.cpp
===
--- test/SemaCXX/alias-template.cpp
+++ test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 
'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}
Index: lib/Sema/SemaTemplateVariadic.cpp
===
--- lib/Sema/SemaTemplateVariadic.cpp
+++ lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);


Index: test/SemaCXX/alias-template.cpp
===
--- test/SemaCXX/alias-template.cpp
+++ test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}
Index: lib/Sema/SemaTemplateVariadic.cpp
===
--- lib/Sema/SemaTemplateVariadic.cpp
+++ lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits