[cfe-commits] r46576 - in /cfe/trunk: CodeGen/CGExprConstant.cpp test/CodeGen/init-with-member-expr.c
Lauro Ramos Venancio
lauro.venancio at gmail.com
Wed Jan 30 13:23:20 PST 2008
Author: laurov
Date: Wed Jan 30 15:23:20 2008
New Revision: 46576
URL: http://llvm.org/viewvc/llvm-project?rev=46576&view=rev
Log:
getLLVMFieldNo can't be called before emitting the base value.
Added:
cfe/trunk/test/CodeGen/init-with-member-expr.c
Modified:
cfe/trunk/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprConstant.cpp?rev=46576&r1=46575&r2=46576&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/CodeGen/CGExprConstant.cpp Wed Jan 30 15:23:20 2008
@@ -412,12 +412,13 @@
}
case Expr::MemberExprClass: {
MemberExpr* ME = cast<MemberExpr>(E);
- unsigned FieldNumber = CGM.getTypes().getLLVMFieldNo(ME->getMemberDecl());
llvm::Constant *Base;
if (ME->isArrow())
Base = Visit(ME->getBase());
else
Base = EmitLValue(ME->getBase());
+
+ unsigned FieldNumber = CGM.getTypes().getLLVMFieldNo(ME->getMemberDecl());
llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
llvm::Constant *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty,
FieldNumber);
Added: cfe/trunk/test/CodeGen/init-with-member-expr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init-with-member-expr.c?rev=46576&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/init-with-member-expr.c (added)
+++ cfe/trunk/test/CodeGen/init-with-member-expr.c Wed Jan 30 15:23:20 2008
@@ -0,0 +1,9 @@
+// RUN: clang %s -emit-llvm
+struct test {
+ int a;
+};
+
+extern struct test t;
+
+int *b=&t.a;
+
More information about the cfe-commits
mailing list