]> granicus.if.org Git - clang/commitdiff
Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
authorMarina Yatsina <marina.yatsina@intel.com>
Wed, 16 Mar 2016 09:56:58 +0000 (09:56 +0000)
committerMarina Yatsina <marina.yatsina@intel.com>
Wed, 16 Mar 2016 09:56:58 +0000 (09:56 +0000)
The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed.
This patch is meant to help the following review: http://reviews.llvm.org/D18123.
The functionality is covered by the tests in my original commit (255890)
The test case in this patch was added to test a bug caught in the review of the first version of this fix.

Differential Revision: http://reviews.llvm.org/D18175

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263630 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmtAsm.cpp
test/CodeGen/ms-inline-asm-errors.cpp [new file with mode: 0644]

index 11a4f8bfa85c98c499336bee7df2ada3275bdff0..cd4269cd7eae37189d61c7476a9fbc30dbc76896 100644 (file)
@@ -623,16 +623,12 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member,
 
   if (!LookupName(BaseResult, getCurScope()))
     return true;
-
-  LookupResult CurrBaseResult(BaseResult);
-
+  
+  if(!BaseResult.isSingleResult())
+    return true;
+  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   for (StringRef NextMember : Members) {
-
-    if (!CurrBaseResult.isSingleResult())
-      return true;
-
     const RecordType *RT = nullptr;
-    NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
     if (VarDecl *VD = dyn_cast<VarDecl>(FoundDecl))
       RT = VD->getType()->getAs<RecordType>();
     else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(FoundDecl)) {
@@ -655,13 +651,15 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member,
     if (!LookupQualifiedName(FieldResult, RT->getDecl()))
       return true;
 
+    if (!FieldResult.isSingleResult())
+      return true;
+    FoundDecl = FieldResult.getFoundDecl();
+
     // FIXME: Handle IndirectFieldDecl?
-    FieldDecl *FD = dyn_cast<FieldDecl>(FieldResult.getFoundDecl());
+    FieldDecl *FD = dyn_cast<FieldDecl>(FoundDecl);
     if (!FD)
       return true;
 
-    CurrBaseResult = FieldResult;
-
     const ASTRecordLayout &RL = Context.getASTRecordLayout(RT->getDecl());
     unsigned i = FD->getFieldIndex();
     CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
diff --git a/test/CodeGen/ms-inline-asm-errors.cpp b/test/CodeGen/ms-inline-asm-errors.cpp
new file mode 100644 (file)
index 0000000..6484743
--- /dev/null
@@ -0,0 +1,15 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify
+
+class A {
+public:
+  void foo(int a)   {}
+  void foo(float a) {}
+};
+
+
+void t_fail() {
+       __asm {
+               mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}}
+       }
+}