зеркало из https://github.com/microsoft/clang-1.git
Template instantiation for imaginary literals, because they were next in Expr.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
bce831b1ec
Коммит
d8ac436c8c
|
@ -523,6 +523,8 @@ public:
|
|||
Expr *getSubExpr() { return cast<Expr>(Val); }
|
||||
void setSubExpr(Expr *E) { Val = E; }
|
||||
|
||||
ImaginaryLiteral* Clone(ASTContext &C) const;
|
||||
|
||||
virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == ImaginaryLiteralClass;
|
||||
|
|
|
@ -44,6 +44,16 @@ FloatingLiteral* FloatingLiteral::Clone(ASTContext &C) const {
|
|||
return new (C) FloatingLiteral(Value, &exact, getType(), Loc);
|
||||
}
|
||||
|
||||
ImaginaryLiteral* ImaginaryLiteral::Clone(ASTContext &C) const {
|
||||
// FIXME: Use virtual Clone(), once it is available
|
||||
Expr *ClonedVal = 0;
|
||||
if (const IntegerLiteral *IntLit = dyn_cast<IntegerLiteral>(Val))
|
||||
ClonedVal = IntLit->Clone(C);
|
||||
else
|
||||
ClonedVal = cast<FloatingLiteral>(Val)->Clone(C);
|
||||
return new (C) ImaginaryLiteral(ClonedVal, getType());
|
||||
}
|
||||
|
||||
GNUNullExpr* GNUNullExpr::Clone(ASTContext &C) const {
|
||||
return new (C) GNUNullExpr(getType(), TokenLoc);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace {
|
|||
OwningExprResult VisitFloatingLiteral(FloatingLiteral *E);
|
||||
OwningExprResult VisitStringLiteral(StringLiteral *E);
|
||||
OwningExprResult VisitCharacterLiteral(CharacterLiteral *E);
|
||||
OwningExprResult VisitImaginaryLiteral(ImaginaryLiteral *E);
|
||||
OwningExprResult VisitDeclRefExpr(DeclRefExpr *E);
|
||||
OwningExprResult VisitParenExpr(ParenExpr *E);
|
||||
OwningExprResult VisitUnaryOperator(UnaryOperator *E);
|
||||
|
@ -91,6 +92,11 @@ TemplateExprInstantiator::VisitCharacterLiteral(CharacterLiteral *E) {
|
|||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitImaginaryLiteral(ImaginaryLiteral *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
||||
return SemaRef.Clone(E);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
template<typename T>
|
||||
struct ImaginaryLiteral0 {
|
||||
void f(T &x) {
|
||||
x = 3.0I; // expected-error{{incompatible type}}
|
||||
}
|
||||
};
|
||||
|
||||
template struct ImaginaryLiteral0<_Complex float>;
|
||||
template struct ImaginaryLiteral0<int*>; // expected-note{{instantiation}}
|
Загрузка…
Ссылка в новой задаче