summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/new-delete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-13 15:54:32 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-13 15:54:32 +0000
commitf2753b3b4efbd01c91a7e6223cc06f7acb9eb31c (patch)
treedd82b3f393c64f609d2108b444f6afad3a3c565a /clang/test/SemaCXX/new-delete.cpp
parentf88a284579bfcaf8a3ee55211f3307e37dd3236a (diff)
downloadbcm5719-llvm-f2753b3b4efbd01c91a7e6223cc06f7acb9eb31c.tar.gz
bcm5719-llvm-f2753b3b4efbd01c91a7e6223cc06f7acb9eb31c.zip
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. <rdar://problem/8018245>. llvm-svn: 108242
Diffstat (limited to 'clang/test/SemaCXX/new-delete.cpp')
-rw-r--r--clang/test/SemaCXX/new-delete.cpp24
1 files changed, 23 insertions, 1 deletions
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<typename T>
+ int *f() {
+ return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}}
+ }
+
+ template int *f<X0>();
+ template int *f<X1>(); // expected-note{{in instantiation of}}
+
+}
OpenPOWER on IntegriCloud