diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-19 16:47:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-19 16:47:56 +0000 |
commit | 0286b467027756abe8749949c5f998c6004345e3 (patch) | |
tree | ad9cac0c77333c6ff063f7dd61d8c7abe3484c44 | |
parent | 337caf9e3e19444a658db6febd1ff697febaa745 (diff) | |
download | bcm5719-llvm-0286b467027756abe8749949c5f998c6004345e3.tar.gz bcm5719-llvm-0286b467027756abe8749949c5f998c6004345e3.zip |
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>.
llvm-svn: 96679
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaObjCXX/vla.mm | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 8aa69363bee..62b10a316e6 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -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/clang/test/SemaObjCXX/vla.mm b/clang/test/SemaObjCXX/vla.mm new file mode 100644 index 00000000000..9c6fc54f817 --- /dev/null +++ b/clang/test/SemaObjCXX/vla.mm @@ -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]; +} + |