]> granicus.if.org Git - clang/commitdiff
Fixes an assertion violation when bind to temporary
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 2 Nov 2010 21:05:53 +0000 (21:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 2 Nov 2010 21:05:53 +0000 (21:05 +0000)
expression is a dependent expression.
// rdar: // 8620524 and PR7851

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

include/clang/AST/ExprCXX.h
lib/AST/ExprCXX.cpp
test/CodeGenCXX/template-dependent-bind-temporary.cpp [new file with mode: 0644]

index a0a059ef95b5b45da8c8e09ab9fe6cfb1bd22f54..3b8ecf293071ac6ce99db69b6a17c5ec66a1ebcf 100644 (file)
@@ -672,8 +672,9 @@ class CXXBindTemporaryExpr : public Expr {
 
   Stmt *SubExpr;
 
-  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
-   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
+  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr, 
+                       bool TD=false, bool VD=false)
+   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), TD, VD),
      Temp(temp), SubExpr(subexpr) { }
 
 public:
index 05b6fc1f6c4edd873d4d670dc59d1dddf781afd6..a07d7840f0c24d137ee58297dabccc77366d258a 100644 (file)
@@ -534,7 +534,9 @@ CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
   assert(SubExpr->getType()->isRecordType() &&
          "Expression bound to a temporary must have record type!");
 
-  return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
+  return new (C) CXXBindTemporaryExpr(Temp, SubExpr,
+                                      SubExpr->isTypeDependent(),
+                                      SubExpr->isValueDependent());
 }
 
 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
diff --git a/test/CodeGenCXX/template-dependent-bind-temporary.cpp b/test/CodeGenCXX/template-dependent-bind-temporary.cpp
new file mode 100644 (file)
index 0000000..cc1ce86
--- /dev/null
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar: //8620524
+// PR7851
+struct string {
+  string (const string& );
+  string ();
+  ~string();
+};
+
+string operator + (char ch, const string&);
+
+template <class T>
+void IntToString(T a)
+{
+ string result;
+ T digit; 
+ char((digit < 10 ? '0' : 'a') + digit) + result;
+}
+
+int main() {
+// CHECK: define linkonce_odr void @_Z11IntToStringIcEvT_(
+  IntToString('a');
+}
+