diff options
| author | Anders Carlsson <andersca@mac.com> | 2008-08-24 16:33:25 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2008-08-24 16:33:25 +0000 |
| commit | c7c20702b1e31c2d80e8a4855fddfb8628cba039 (patch) | |
| tree | e2f8dd2f3cd9609e3918257462ed38079f1ba8fc | |
| parent | bf667e23d113319bc2161879a0f588ba6509105c (diff) | |
| download | bcm5719-llvm-c7c20702b1e31c2d80e8a4855fddfb8628cba039.tar.gz bcm5719-llvm-c7c20702b1e31c2d80e8a4855fddfb8628cba039.zip | |
Fix silly bug in objc_gc attribute parsing and add test case
llvm-svn: 55286
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaObjC/objc-gc-attr.m | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 2cfb3b9b96a..f94711e987c 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -467,7 +467,7 @@ static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) { } static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) { - if (!Attr.getParameterName()) { + if (!Attr.getParameterName()) { S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string, "objc_gc", std::string("1")); return; @@ -486,7 +486,7 @@ static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) { if (TypeLen == 4 && !memcmp(TypeStr, "weak", 4)) type = ObjCGCAttr::Weak; - else if (TypeLen == 5 && !memcmp(TypeStr, "strong", 5)) + else if (TypeLen == 6 && !memcmp(TypeStr, "strong", 6)) type = ObjCGCAttr::Strong; else { S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported, diff --git a/clang/test/SemaObjC/objc-gc-attr.m b/clang/test/SemaObjC/objc-gc-attr.m new file mode 100644 index 00000000000..1f2db346a1b --- /dev/null +++ b/clang/test/SemaObjC/objc-gc-attr.m @@ -0,0 +1,8 @@ +// RUN: clang -fsyntax-only -verify %s +static id __attribute((objc_gc(weak))) a; +static id __attribute((objc_gc(strong))) b; + +static id __attribute((objc_gc())) c; // expected-error{{'objc_gc' attribute requires parameter 1 to be a string}} +static id __attribute((objc_gc(123))) d; // expected-error{{'objc_gc' attribute requires parameter 1 to be a string}} +static id __attribute((objc_gc(foo, 456))) e; // expected-error{{attribute requires 1 argument(s)}} +static id __attribute((objc_gc(hello))) f; // expected-warning{{'objc_gc' attribute argument not supported: 'hello'}} |

