]> granicus.if.org Git - clang/commitdiff
Only parse C++0x attribute specifiers in declarators when in C++0x
authorDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 16:47:56 +0000 (16:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 16:47:56 +0000 (16:47 +0000)
mode. This allows us to detect invalid VLAs in Objective-C++
mode. This should be the last of <rdar://problem/7660386>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96679 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/SemaObjCXX/vla.mm [new file with mode: 0644]

index 8aa69363beeedd1bd8533a47fd232b257f0e57d9..62b10a316e6033bf0e016812a5d839bb57fad1fc 100644 (file)
@@ -2588,7 +2588,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
          "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();
diff --git a/test/SemaObjCXX/vla.mm b/test/SemaObjCXX/vla.mm
new file mode 100644 (file)
index 0000000..9c6fc54
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Data
+- (unsigned)length;
+- (void)getData:(void*)buffer;
+@end
+
+void test(Data *d) {
+  char buffer[[d length]]; // expected-error{{variable length arrays are not permitted in C++}}
+  [d getData:buffer];
+}
+