[cfe-commits] r90555 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/member-expr-anonymous-union.cpp test/SemaCXX/offsetof.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Dec 3 23:18:52 PST 2009
Author: efriedma
Date: Fri Dec 4 01:18:51 2009
New Revision: 90555
URL: http://llvm.org/viewvc/llvm-project?rev=90555&view=rev
Log:
Make sure to call PerformObjectMemberConversion where necessary.
Added:
cfe/trunk/test/SemaCXX/member-expr-anonymous-union.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/offsetof.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=90555&r1=90554&r2=90555&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 4 01:18:51 2009
@@ -605,6 +605,7 @@
MemberType = Context.getQualifiedType(MemberType, NewQuals);
MarkDeclarationReferenced(Loc, *FI);
+ PerformObjectMemberConversion(Result, *FI);
// FIXME: Might this end up being a qualified name?
Result = new (Context) MemberExpr(Result, BaseObjectIsPointer, *FI,
OpLoc, MemberType);
@@ -2397,7 +2398,8 @@
if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
// We may have found a field within an anonymous union or struct
// (C++ [class.union]).
- if (cast<RecordDecl>(FD->getDeclContext())->isAnonymousStructOrUnion())
+ if (cast<RecordDecl>(FD->getDeclContext())->isAnonymousStructOrUnion() &&
+ !BaseType->getAs<RecordType>()->getDecl()->isAnonymousStructOrUnion())
return BuildAnonymousStructUnionMemberReference(MemberLoc, FD,
BaseExpr, OpLoc);
@@ -6397,6 +6399,7 @@
Res = BuildAnonymousStructUnionMemberReference(
OC.LocEnd, MemberDecl, Res, OC.LocEnd).takeAs<Expr>();
} else {
+ PerformObjectMemberConversion(Res, MemberDecl);
// MemberDecl->getType() doesn't get the right qualifiers, but it
// doesn't matter here.
Res = new (Context) MemberExpr(Res, false, MemberDecl, OC.LocEnd,
Added: cfe/trunk/test/SemaCXX/member-expr-anonymous-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr-anonymous-union.cpp?rev=90555&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr-anonymous-union.cpp (added)
+++ cfe/trunk/test/SemaCXX/member-expr-anonymous-union.cpp Fri Dec 4 01:18:51 2009
@@ -0,0 +1,9 @@
+// RUN: clang-cc %s -fsyntax-only -verify
+// PR5543
+
+struct A { int x; union { int* y; float& z; }; }; struct B : A {int a;};
+int* a(B* x) { return x->y; }
+
+struct x { union { int y; }; }; x y; template <int X> int f() { return X+y.y; }
+int g() { return f<2>(); }
+
Modified: cfe/trunk/test/SemaCXX/offsetof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/offsetof.cpp?rev=90555&r1=90554&r2=90555&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/offsetof.cpp (original)
+++ cfe/trunk/test/SemaCXX/offsetof.cpp Fri Dec 4 01:18:51 2009
@@ -13,3 +13,6 @@
int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'struct P'}}
}
+struct Base { int x; };
+struct Derived : Base { int y; };
+int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
More information about the cfe-commits
mailing list