diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-07-25 19:45:01 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-07-25 19:45:01 +0000 |
commit | a57d91c2aede9cb8c5e43ab86cfaebe4e43f0161 (patch) | |
tree | 8e3c6ec2d1f652c077adfccb29dd52b7f481465c /clang/lib/Sema/SemaExpr.cpp | |
parent | e5b6e0d2313cdd5b906bfeaf3968ff7fdd6438db (diff) | |
download | bcm5719-llvm-a57d91c2aede9cb8c5e43ab86cfaebe4e43f0161.tar.gz bcm5719-llvm-a57d91c2aede9cb8c5e43ab86cfaebe4e43f0161.zip |
Objective-C. Warn if protocol used in an @protocol
expression is a forward declaration as this results
in undefined behavior. rdar://17768630
llvm-svn: 213968
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 163973bd55f..c2c886c04ea 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6756,6 +6756,15 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, return Incompatible; } + Expr *PRE = RHS.get()->IgnoreParenCasts(); + if (ObjCProtocolExpr *OPE = dyn_cast<ObjCProtocolExpr>(PRE)) { + ObjCProtocolDecl *PDecl = OPE->getProtocol(); + if (PDecl && !PDecl->hasDefinition()) { + Diag(PRE->getExprLoc(), diag::warn_atprotocol_protocol) << PDecl->getName(); + Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl; + } + } + CastKind Kind = CK_Invalid; Sema::AssignConvertType result = CheckAssignmentConstraints(LHSType, RHS, Kind); |