[cfe-commits] r81309 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/static-array-member.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 8 18:45:29 PDT 2009
Author: dgregor
Date: Tue Sep 8 20:45:28 2009
New Revision: 81309
URL: http://llvm.org/viewvc/llvm-project?rev=81309&view=rev
Log:
Allow a declaration of an array to complete a prior, incomplete
declaration of that array in C++.
Added:
cfe/trunk/test/SemaCXX/static-array-member.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81309&r1=81308&r2=81309&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 8 20:45:28 2009
@@ -980,6 +980,13 @@
if (getLangOptions().CPlusPlus) {
if (Context.hasSameType(New->getType(), Old->getType()))
MergedT = New->getType();
+ // C++ [basic.types]p7:
+ // [...] The declared type of an array object might be an array of
+ // unknown size and therefore be incomplete at one point in a
+ // translation unit and complete later on; [...]
+ else if (Old->getType()->isIncompleteArrayType() &&
+ New->getType()->isArrayType())
+ MergedT = New->getType();
} else {
MergedT = Context.mergeTypes(New->getType(), Old->getType());
}
Added: cfe/trunk/test/SemaCXX/static-array-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-array-member.cpp?rev=81309&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/static-array-member.cpp (added)
+++ cfe/trunk/test/SemaCXX/static-array-member.cpp Tue Sep 8 20:45:28 2009
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only %s
+
+struct X0 {
+ static int array[];
+
+ int x;
+ int y;
+};
+
+int X0::array[sizeof(X0) * 2];
+
+template<typename T, int N>
+struct X1 {
+ static T array[];
+};
+
+template<typename T, int N>
+T X1<T, N>::array[N];
Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list