[PATCH] D18997: [SemaObjC] Properly diagnose type arguments and protocols mix in parameterized classes

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 11 17:09:13 PDT 2016


bruno created this revision.
bruno added a reviewer: doug.gregor.
bruno added subscribers: manmanren, dexonsmith, cfe-commits.

Under certain conditions clang currently fails to properly diagnostic ObjectC
parameter list when type args and protocols are mixed in the same list. This
happens when the first item in the parameter list is a (1) protocol, (2)
unknown type or (3) a list of protocols/unknown types up to the first type
argument. Fix the problem to report the proper error, example:

NSArray<M, NSValue *, NSURL, NSArray <id <M>>> *foo = @[@"a"];
NSNumber *bar = foo[0];
NSLog(@"%@", bar);

$ clang ...
x.m:7:13: error: angle brackets contain both a type ('NSValue') and a protocol ('M')
        NSArray<M, NSValue *, NSURL, NSArray <id <M>>> *foo = @[@"a"];
                ~  ^

http://reviews.llvm.org/D18997

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseObjc.cpp
  lib/Sema/SemaDeclObjC.cpp
  test/SemaObjC/parameterized_classes.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18997.53339.patch
Type: text/x-patch
Size: 5871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160412/ff16a8b1/attachment.bin>


More information about the cfe-commits mailing list