[cfe-commits] r96679 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaObjCXX/vla.mm
Douglas Gregor
dgregor at apple.com
Fri Feb 19 08:47:56 PST 2010
Author: dgregor
Date: Fri Feb 19 10:47:56 2010
New Revision: 96679
URL: http://llvm.org/viewvc/llvm-project?rev=96679&view=rev
Log:
Only parse C++0x attribute specifiers in declarators when in C++0x
mode. This allows us to detect invalid VLAs in Objective-C++
mode. This should be the last of <rdar://problem/7660386>.
Added:
cfe/trunk/test/SemaObjCXX/vla.mm
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=96679&r1=96678&r2=96679&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Feb 19 10:47:56 2010
@@ -2588,7 +2588,7 @@
"Haven't past the location of the identifier yet?");
// Don't parse attributes unless we have an identifier.
- if (D.getIdentifier() && getLang().CPlusPlus
+ if (D.getIdentifier() && getLang().CPlusPlus0x
&& isCXX0XAttributeSpecifier(true)) {
SourceLocation AttrEndLoc;
CXX0XAttributeList Attr = ParseCXX0XAttributes();
Added: cfe/trunk/test/SemaObjCXX/vla.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/vla.mm?rev=96679&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/vla.mm (added)
+++ cfe/trunk/test/SemaObjCXX/vla.mm Fri Feb 19 10:47:56 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface Data
+- (unsigned)length;
+- (void)getData:(void*)buffer;
+ at end
+
+void test(Data *d) {
+ char buffer[[d length]]; // expected-error{{variable length arrays are not permitted in C++}}
+ [d getData:buffer];
+}
+
More information about the cfe-commits
mailing list