diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaObjC/conflict-nonfragile-abi2.m | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index ba156b16cfb..486002292d1 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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<NonfragileAbi2>; +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/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f7b450d2c9d..59d0328d6e1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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<FunctionDecl>()) { diff --git a/clang/test/SemaObjC/conflict-nonfragile-abi2.m b/clang/test/SemaObjC/conflict-nonfragile-abi2.m index 14e666000c6..e4b513f7531 100644 --- a/clang/test/SemaObjC/conflict-nonfragile-abi2.m +++ b/clang/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 { |