* C++ PATCH for c++/55520 (ICE with lambda capture of VLA)
@ 2013-06-07 3:12 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2013-06-07 3:12 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 207 bytes --]
I recently implemented capture of C++14 VLAs, but the VLA in this
testcase is not valid C++14, so capturing it isn't supported. But we
still shouldn't ICE.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 55520.patch --]
[-- Type: text/x-patch, Size: 1514 bytes --]
commit c0ecc17471e7859ba36f3f8d095e5666e525f84f
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jun 6 22:41:32 2013 -0400
PR c++/55520
* semantics.c (add_capture): Diagnose capture of variable-size
type that is not a C++1y array of runtime bound.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 048a7db..b5c3b0a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9487,6 +9487,15 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p,
nelts_field, array_type_nelts (type));
type = ctype;
}
+ else if (variably_modified_type_p (type, NULL_TREE))
+ {
+ error ("capture of variable-size type %qT that is not a C++1y array "
+ "of runtime bound", type);
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && variably_modified_type_p (TREE_TYPE (type), NULL_TREE))
+ inform (input_location, "because the array element type %qT has "
+ "variable size", TREE_TYPE (type));
+ }
else if (by_reference_p)
{
type = build_reference_type (type);
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla7.C b/gcc/testsuite/g++.dg/cpp1y/vla7.C
new file mode 100644
index 0000000..df34c82
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/vla7.C
@@ -0,0 +1,12 @@
+// PR c++/55520
+// { dg-options "-Wno-vla" }
+// { dg-require-effective-target c++11 }
+
+int main(int argc, char** argv)
+{
+ int x[1][argc];
+
+ [&x](int i) { // { dg-error "variable.size" }
+ x[0][i] = 0; // { dg-prune-output "assignment" }
+ }(5);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-07 3:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 3:12 C++ PATCH for c++/55520 (ICE with lambda capture of VLA) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).