From f2753b3b4efbd01c91a7e6223cc06f7acb9eb31c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 13 Jul 2010 15:54:32 +0000 Subject: Downgrade the "when type is in parentheses, array cannot have dynamic size" error for code like new (int [size]) to a warning, add a Fix-It to remove the parentheses, and make this diagnostic work properly when it occurs in a template instantiation. . llvm-svn: 108242 --- clang/test/SemaCXX/new-delete.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'clang/test/SemaCXX/new-delete.cpp') diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp index 34588c2ae11..25bf823b255 100644 --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -68,7 +68,7 @@ void bad_news(int *ip) (void)new int[1.1]; // expected-error {{array size expression must have integral or enumerated type, not 'double'}} (void)new int[1][i]; // expected-error {{only the first dimension}} (void)new (int[1][i]); // expected-error {{only the first dimension}} - (void)new (int[i]); // expected-error {{when type is in parentheses}} + (void)new (int[i]); // expected-warning {{when type is in parentheses}} (void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}} (void)new int(1, 2); // expected-error {{excess elements in scalar initializer}} (void)new S(1); // expected-error {{no matching constructor}} @@ -288,3 +288,25 @@ void test(S1* s1, S2* s2) { } } +namespace rdar8018245 { + struct X0 { + static const int value = 17; + }; + + const int X0::value; + + struct X1 { + static int value; + }; + + int X1::value; + + template + int *f() { + return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}} + } + + template int *f(); + template int *f(); // expected-note{{in instantiation of}} + +} -- cgit v1.2.3