]> granicus.if.org Git - clang/commitdiff
CodeGen: Fix a silly typo when emitting subs of block addresses.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 3 Oct 2012 14:15:39 +0000 (14:15 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 3 Oct 2012 14:15:39 +0000 (14:15 +0000)
Part of PR14005.

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

lib/AST/ExprConstant.cpp
test/CodeGen/const-label-addr.c

index 05912fc1c5a9f0f381138734e915e1b166151c25..e21c83b64f67b6166b9b6e01100aaa5678cf682c 100644 (file)
@@ -4919,7 +4919,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
           if (!LHSValue.Offset.isZero() || !RHSValue.Offset.isZero())
             return false;
           const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr*>();
-          const Expr *RHSExpr = LHSValue.Base.dyn_cast<const Expr*>();
+          const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr*>();
           if (!LHSExpr || !RHSExpr)
             return false;
           const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
index 9d99f88c8a65091bb34b7c6196c79fa8dc687c08..e2fe38750ff9d18c03994ef2992eb98c72a6cde5 100644 (file)
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 %s -emit-llvm -o %t
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @a.a = internal global i8* blockaddress(@a, %A)
 int a() {
 A:;static void* a = &&A;
 }
+
+// PR14005
+// CHECK: @b.ar = internal global {{.*}} sub (i{{..}} ptrtoint (i8* blockaddress(@b, %l2) to i{{..}}), i{{..}} ptrtoint (i8* blockaddress(@b, %l1) to i{{..}}))
+int b() {
+  static int ar = &&l2 - &&l1;
+l1:
+  return 10;
+l2:
+  return 11;
+}