"invalid input constraint '%0' in asm">;
def err_asm_invalid_type_in_input : Error<
"invalid type %0 in asm input for constraint '%1'">;
+def err_asm_tying_incompatible_types : Error<
+ "unsupported inline asm: input with type %0 matching output with type %1">;
def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
def err_invalid_asm_cast_lvalue : Error<
"invalid use of a cast in a inline asm context requiring an l-value: "
}
DefaultFunctionArrayConversion(Exprs[i]);
+
+ // If this is a tied constraint, verify that the output and input have
+ // either exactly the same type, or that they are int/ptr operands with the
+ // same size (int/long, int*/long, are ok etc).
+ if (Info.hasTiedOperand()) {
+ unsigned TiedTo = Info.getTiedOperand();
+ QualType T1 = Exprs[TiedTo]->getType(), T2 = Exprs[i]->getType();
+ if (!Context.hasSameType(T1, T2)) {
+ // Int/ptr operands are ok if they are the same size.
+ if (!(T1->isIntegerType() || T1->isPointerType()) ||
+ !(T2->isIntegerType() || T2->isPointerType()) ||
+ Context.getTypeSize(T1) != Context.getTypeSize(T2))
+ return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(),
+ diag::err_asm_tying_incompatible_types)
+ << T2 << T1 << Exprs[TiedTo]->getSourceRange()
+ << Exprs[i]->getSourceRange());
+ }
+ }
}
// Check that the clobbers are valid.
asm("%9" :: "i"(4)); // expected-error {{invalid operand number in inline asm string}}
asm("%1" : "+r"(i)); // ok, referring to input.
}
+
+// PR4077
+int test7(unsigned long long b) {
+ int a;
+ asm volatile("foo " : "=a" (a) :"0" (b)); // expected-error {{input with type 'unsigned long long' matching output with type 'int'}}
+ return a;
+}