]> granicus.if.org Git - clang/commitdiff
Add test case for PR5868, and improve location information slightly for implicit...
authorDouglas Gregor <dgregor@apple.com>
Thu, 24 Dec 2009 20:23:34 +0000 (20:23 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 24 Dec 2009 20:23:34 +0000 (20:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92141 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/TreeTransform.h
test/SemaTemplate/anonymous-union.cpp [new file with mode: 0644]

index a9acf72644c69ad961fbebb7c5f062c40dede18f..5902e371c5aea95df068089e4bf4342a094ad952 100644 (file)
@@ -564,7 +564,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
                == Context.getCanonicalType(ThisType)) ||
             IsDerivedFrom(ThisType, AnonFieldType)) {
           // Our base object expression is "this".
-          BaseObjectExpr = new (Context) CXXThisExpr(SourceLocation(),
+          BaseObjectExpr = new (Context) CXXThisExpr(Loc,
                                                      MD->getThisType(Context));
           BaseObjectIsPointer = true;
         }
index 61b57e7e5642bae3412fb97fa070286efac18dff..7db723bdb921053069a555a4391f7320371cbda3 100644 (file)
@@ -959,6 +959,7 @@ public:
       Expr *BaseExpr = Base.takeAs<Expr>();
       if (getSema().PerformObjectMemberConversion(BaseExpr, Member))
         return getSema().ExprError();
+
       MemberExpr *ME =
         new (getSema().Context) MemberExpr(BaseExpr, isArrow,
                                            Member, MemberLoc,
diff --git a/test/SemaTemplate/anonymous-union.cpp b/test/SemaTemplate/anonymous-union.cpp
new file mode 100644 (file)
index 0000000..59d1f25
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5868
+struct T0 {
+  int x;
+  union {
+    void *m0;
+  };
+};
+template <typename T>
+struct T1 : public T0, public T { 
+  void f0() { 
+    m0 = 0; // expected-error{{ambiguous conversion}}
+  } 
+};
+
+struct A : public T0 { };
+
+void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}}