aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-15 17:58:33 +0000
committerChris Lattner <sabre@nondot.org>2002-08-15 17:58:33 +0000
commit3101c25293447cf939759ec2bd9a6a003eb284ad (patch)
tree3cd002623f7e5d5eb4e726138581da143ec701cd /lib/AsmParser
parent657882cf6e9be3d409fbcf773fb8eaa67180c4e3 (diff)
downloadexternal_llvm-3101c25293447cf939759ec2bd9a6a003eb284ad.zip
external_llvm-3101c25293447cf939759ec2bd9a6a003eb284ad.tar.gz
external_llvm-3101c25293447cf939759ec2bd9a6a003eb284ad.tar.bz2
Fix bug: test/Regression/Assembler/2002-08-15-UnresolvedGlobalReference.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/llvmAsmParser.y14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 923e48d..0175d65 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -919,8 +919,21 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
if (Ty == 0)
ThrowException("Global const reference must be a pointer type!");
+ // ConstExprs can exist in the body of a function, thus creating
+ // ConstantPointerRefs whenever they refer to a variable. Because we are in
+ // the context of a function, getValNonImprovising will search the functions
+ // symbol table instead of the module symbol table for the global symbol,
+ // which throws things all off. To get around this, we just tell
+ // getValNonImprovising that we are at global scope here.
+ //
+ Function *SavedCurFn = CurMeth.CurrentFunction;
+ CurMeth.CurrentFunction = 0;
+
Value *V = getValNonImprovising(Ty, $2);
+ CurMeth.CurrentFunction = SavedCurFn;
+
+
// If this is an initializer for a constant pointer, which is referencing a
// (currently) undefined variable, create a stub now that shall be replaced
// in the future with the right type of variable.
@@ -960,7 +973,6 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
};
-// FIXME: ConstExpr::get never return null! Do checking here in the parser.
ConstExpr: Types CAST ConstVal {
$$ = ConstantExpr::getCast($3, $1->get());
delete $1;