[cfe-dev] Allow implicit copy constructor between address spaces in C++
Adam Strzelecki
ono at java.pl
Sun May 4 17:08:01 PDT 2014
Unfortunately it doesn’t work for me. Clang throws an assertion about what I should do, while I am trying do exactly opposite :>
clang-3.5: /home/ono/Projects/llvm/tools/clang/lib/AST/ExprClassification.cpp:619: clang::Expr::Classification::ModifiableType IsModifiable(clang::ASTContext&, const clang::Expr*, clang::Expr::Classification::Kinds, clang::SourceLocation&): Assertion `(E->getObjectKind() == OK_ObjCProperty || !Ctx.getLangOpts().CPlusPlus) && "C++ struct assignment should be resolved by the " "copy assignment operator."' failed.
Code I am testing on:
typedef struct Point { float x, y; } Point;
float test(int i, //
__attribute__((address_space(1))) const Point *in,
__attribute__((address_space(1))) Point *out) {
Point r;
__builtin_assign(r, in[i]);
out[i] = r;
return r.x * r.y;
}
Change proposed by Alp:
--- a/include/clang/Basic/Builtins.def
+++ b/include/clang/Basic/Builtins.def
@@ -1204,6 +1204,7 @@ BUILTIN(__builtin_smulll_overflow, "bSLLiCSLLiCSLLi*", "n")
// Clang builtins (not available in GCC).
BUILTIN(__builtin_addressof, "v*v&", "nct")
+BUILTIN(__builtin_assign, "v.", "t")
#undef BUILTIN
#undef LIBBUILTIN
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -296,6 +296,12 @@ Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
if (SemaBuiltinAddressof(*this, TheCall))
return ExprError();
break;
+ case Builtin::BI__builtin_assign:
+ if (checkArgCount(*this, TheCall, 2))
+ return true;
+ return CreateBuiltinBinOp(TheCall->getLocStart(), BO_Assign,
+ TheCall->getArg(0), TheCall->getArg(1));
+ break;
}
More information about the cfe-dev
mailing list