From: Fariborz Jahanian Date: Fri, 13 Aug 2010 18:09:39 +0000 (+0000) Subject: When issuing warning for future conflict resolution, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f759b4dc74fe8b0cc6e1350b860676ac9b853371;p=clang When issuing warning for future conflict resolution, (nonfragile-abi2), do not consider 'ivar' access in class methods. Also, improve on diagnostics. Radar 8304561. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111023 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index ba156b16cf..486002292d 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2520,8 +2520,10 @@ def note_condition_assign_silence : Note< "place parentheses around the assignment to silence this warning">; def warn_ivar_variable_conflict : Warning< - "%0 lookup will access the property ivar in nonfragile-abi2 mode">, + "when default property synthesis is on, " + "%0 lookup will access property ivar instead of global variable">, InGroup; +def note_global_declared_at : Note<"global variable declared here">; // assignment related diagnostics (also for argument passing, returning, etc). // In most of these diagnostics the %2 is a value from the diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f7b450d2c9..59d0328d6e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1142,6 +1142,8 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S, return ActOnIdExpression(S, SS, Id, HasTrailingLParen, isAddressOfOperand); } + // for further use, this must be set to false if in class method. + IvarLookupFollowUp = getCurMethodDecl()->isInstanceMethod(); } } @@ -1193,6 +1195,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S, if (Property) { Diag(NameLoc, diag::warn_ivar_variable_conflict) << Var->getDeclName(); Diag(Property->getLocation(), diag::note_property_declare); + Diag(Var->getLocation(), diag::note_global_declared_at); } } } else if (FunctionDecl *Func = R.getAsSingle()) { diff --git a/test/SemaObjC/conflict-nonfragile-abi2.m b/test/SemaObjC/conflict-nonfragile-abi2.m index 14e666000c..e4b513f753 100644 --- a/test/SemaObjC/conflict-nonfragile-abi2.m +++ b/test/SemaObjC/conflict-nonfragile-abi2.m @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s // rdar : // 8225011 -int glob; +int glob; // expected-note {{global variable declared here}} @interface I @property int glob; // expected-note {{property declared here}} @@ -13,7 +13,7 @@ int glob; @end @implementation I -- (int) Meth { return glob; } // expected-warning {{'glob' lookup will access the property ivar in nonfragile-abi2 mode}} +- (int) Meth { return glob; } // expected-warning {{when default property synthesis is on, 'glob' lookup will access}} @synthesize glob; // rdar: // 8248681 - (int) Meth1: (int) p {