summaryrefslogtreecommitdiff
path: root/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp')
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
new file mode 100644
index 0000000..bb4a48e
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+// Simple form
+int ar1[10];
+
+// Element type cannot be:
+// - (cv) void
+volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}}
+// - a reference
+int& ar3[10]; // expected-error {{array of references}}
+// - a function type
+typedef void Fn();
+Fn ar4[10]; // expected-error {{array of functions}}
+// - an abstract class
+struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}}
+Abstract ar5[10]; // expected-error {{abstract class}}
+
+// If we have a size, it must be greater than zero.
+int ar6[-1]; // expected-error {{array with a negative size}}
+int ar7[0u]; // expected-warning {{zero size arrays are an extension}}
+
+// An array with unknown bound is incomplete.
+int ar8[]; // expected-error {{needs an explicit size or an initializer}}
+// So is an array with an incomplete element type.
+struct Incomplete; // expected-note {{forward declaration}}
+Incomplete ar9[10]; // expected-error {{incomplete type}}
+// Neither of which should be a problem in situations where no complete type
+// is required. (PR5048)
+void fun(int p1[], Incomplete p2[10]);
+extern int ear1[];
+extern Incomplete ear2[10];
+
+// cv migrates to element type
+typedef const int cint;
+extern cint car1[10];
+typedef int intar[10];
+// thus this is a valid redeclaration
+extern const intar car1;
+
+// Check that instantiation works properly when the element type is a template.
+template <typename T> struct S {
+ typename T::type x; // expected-error {{has no members}}
+};
+S<int> ar10[10]; // expected-note {{requested here}}
+
+// Ensure that negative array size errors include the name of the declared
+// array as this is often used to simulate static_assert with template
+// instantiations, placing the 'error message' in the declarator name.
+int
+user_error_message
+[-1]; // expected-error {{user_error_message}}
+typedef int
+another_user_error_message
+[-1]; // expected-error {{another_user_error_message}}