From c4284e3aad1299adcbc66ffe02f632c79fd40663 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 23 Sep 2015 16:03:53 +0000 Subject: [Sema] Don't create an invalid source range for overlong initializer lists. We took both source locations from the end of the initializer list what the code below doesn't expect. This can lead to a crash when rendering the diagnostic (PR24816). Assert that we have more than one element in a scalar initializer with too many elements. llvm-svn: 248391 --- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp') diff --git a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp index 0e9a97d5bb0..1b01a351f78 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -129,3 +129,7 @@ namespace array_addressof { using T = int[5]; T *p = &T{1,2,3,4,5}; // expected-error {{taking the address of a temporary object of type 'T' (aka 'int [5]')}} } + +namespace PR24816 { + struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}} +} -- cgit v1.2.3