]> granicus.if.org Git - clang/commitdiff
When issuing warning for future conflict resolution,
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 13 Aug 2010 18:09:39 +0000 (18:09 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 13 Aug 2010 18:09:39 +0000 (18:09 +0000)
(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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaObjC/conflict-nonfragile-abi2.m

index ba156b16cfb3438e2af3e278041cc194b13b69e0..486002292d1b4b4a4b9fba29238156d13b1c3c1f 100644 (file)
@@ -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
index f7b450d2c9de98de20d7cd01662eea637d3f16a6..59d0328d6e1248c177769f3e339394e8dfefd4a6 100644 (file)
@@ -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>()) {
index 14e666000c606586530457b0d5a0c9735cd8f5e5..e4b513f75312fa1884af14be47192c98cecf3edf 100644 (file)
@@ -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 {