[cfe-commits] r139716 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/SemaTemplate/instantiate-expr-1.cpp

Eli Friedman eli.friedman at gmail.com
Wed Sep 14 12:20:01 PDT 2011


Author: efriedma
Date: Wed Sep 14 14:20:00 2011
New Revision: 139716

URL: http://llvm.org/viewvc/llvm-project?rev=139716&view=rev
Log:
PR10864: make sure we correctly delay type-checking for inline asm tied operands with dependent type.  Patch by Likai Liu.


Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=139716&r1=139715&r2=139716&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Sep 14 14:20:00 2011
@@ -2121,6 +2121,10 @@
     unsigned InputOpNo = i+NumOutputs;
     Expr *OutputExpr = Exprs[TiedTo];
     Expr *InputExpr = Exprs[InputOpNo];
+
+    if (OutputExpr->isTypeDependent() || InputExpr->isTypeDependent())
+      continue;
+
     QualType InTy = InputExpr->getType();
     QualType OutTy = OutputExpr->getType();
     if (Context.hasSameType(InTy, OutTy))

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp?rev=139716&r1=139715&r2=139716&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp Wed Sep 14 14:20:00 2011
@@ -170,3 +170,16 @@
 
   template void Y2<3>::f();
 }
+
+namespace PR10864 {
+  template<typename T> class Vals {};
+  template<> class Vals<int> { public: static const int i = 1; };
+  template<> class Vals<float> { public: static const double i; };
+  template<typename T> void test_asm_tied(T o) {
+    __asm("addl $1, %0" : "=r" (o) : "0"(Vals<T>::i)); // expected-error {{input with type 'double' matching output with type 'float'}}
+  }
+  void test_asm_tied() {
+    test_asm_tied(1);
+    test_asm_tied(1.f); // expected-note {{instantiation of}}
+  }
+}





More information about the cfe-commits mailing list