From 461a67fa15370a9ec88f8f8a240bf7c123bb2029 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:11:37 +0000 Subject: Vendor import of clang trunk r321017: https://llvm.org/svn/llvm-project/cfe/trunk@321017 --- test/SemaCXX/aggregate-initialization.cpp | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'test/SemaCXX/aggregate-initialization.cpp') diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp index 7b6abd22acc7..514473f9bcb1 100644 --- a/test/SemaCXX/aggregate-initialization.cpp +++ b/test/SemaCXX/aggregate-initialization.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s // Verify that using an initializer list for a non-aggregate looks for // constructors.. @@ -150,3 +150,33 @@ namespace ProtectedBaseCtor { // expected-error@-5 {{protected constructor}} // expected-note@-30 {{here}} } + +namespace IdiomaticStdArrayInitDoesNotWarn { +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wmissing-braces" + template struct StdArray { + T contents[N]; + }; + StdArray x = {1, 2, 3}; + + template struct ArrayAndSomethingElse { + T contents[N]; + int something_else; + }; + ArrayAndSomethingElse y = {1, 2, 3}; // expected-warning {{suggest braces}} + +#if __cplusplus >= 201703L + template struct ArrayAndBaseClass : StdArray { + T contents[N]; + }; + ArrayAndBaseClass z = {1, 2, 3}; // expected-warning {{suggest braces}} + + // It's not clear whether we should be warning in this case. If this + // pattern becomes idiomatic, it would be reasonable to suppress the + // warning here too. + template struct JustABaseClass : StdArray {}; + JustABaseClass w = {1, 2, 3}; // expected-warning {{suggest braces}} +#endif + +#pragma clang diagnostic pop +} -- cgit v1.2.3