diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-05 22:32:48 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-05 22:32:48 +0000 | 
| commit | fbbaf6afaea9715fdba1d2c868287b94eeae189c (patch) | |
| tree | 6dd94f0b42f8994f49e833977ff7f9d37d8b755e /clang/lib/Sema/SemaDeclObjC.cpp | |
| parent | b49d7cf19e943878c24745da2d061bb8f7f1cb5e (diff) | |
| download | bcm5719-llvm-fbbaf6afaea9715fdba1d2c868287b94eeae189c.tar.gz bcm5719-llvm-fbbaf6afaea9715fdba1d2c868287b94eeae189c.zip | |
This test checks for duplicate implementation of the same 
property. It also checks for duplicate use of the same ivar
in two different iproperty implementations. It also caught
an error for a test case used in CodeGen :).
llvm-svn: 60610
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 35 | 
1 files changed, 33 insertions, 2 deletions
| diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index a58d1da6322..03c803054ca 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1506,10 +1506,41 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,                                    ObjCPropertyImplDecl::Synthesize                                     : ObjCPropertyImplDecl::Dynamic),                                   Ivar); -  if (IC) +  if (IC) { +    if (Synthesize) +      if (ObjCPropertyImplDecl *PPIDecl =  +          IC->FindPropertyImplIvarDecl(PropertyIvar)) { +        Diag(PropertyLoc, diag::error_duplicate_ivar_use)  +          << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()  +          << PropertyIvar; +        Diag(PPIDecl->getLocation(), diag::note_previous_use); +      } +     +    if (ObjCPropertyImplDecl *PPIDecl = IC->FindPropertyImplDecl(PropertyId)) { +      Diag(PropertyLoc, diag::error_property_implemented) << PropertyId; +      Diag(PPIDecl->getLocation(), diag::note_previous_declaration); +      return 0; +    }      IC->addPropertyImplementation(PIDecl); -  else +  } +  else { +    if (Synthesize) +      if (ObjCPropertyImplDecl *PPIDecl =  +          CatImplClass->FindPropertyImplIvarDecl(PropertyIvar)) { +        Diag(PropertyLoc, diag::error_duplicate_ivar_use)  +          << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()  +          << PropertyIvar; +        Diag(PPIDecl->getLocation(), diag::note_previous_use); +      } +     +    if (ObjCPropertyImplDecl *PPIDecl =  +          CatImplClass->FindPropertyImplDecl(PropertyId)) { +      Diag(PropertyLoc, diag::error_property_implemented) << PropertyId; +      Diag(PPIDecl->getLocation(), diag::note_previous_declaration); +      return 0; +    }          CatImplClass->addPropertyImplementation(PIDecl); +  }    return PIDecl;  } | 

