[cfe-commits] r81096 - in /cfe/trunk: lib/AST/ExprCXX.cpp lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/default-expr-arguments.cpp

Daniel Dunbar daniel at zuster.org
Sat Sep 5 18:32:55 PDT 2009


Hi Anders,

I reverted this, it was breaking the tests, uh, everywhere. :)

As a friendly reminder, please don't leave tests failing -- if you
can't resolve something just revert your own patch and come back to it
later.

 - Daniel

On Sat, Sep 5, 2009 at 3:51 PM, Anders Carlsson<andersca at mac.com> wrote:
> Author: andersca
> Date: Sat Sep  5 17:51:06 2009
> New Revision: 81096
>
> URL: http://llvm.org/viewvc/llvm-project?rev=81096&view=rev
> Log:
> Initialize default CXXConstructExpr arguments to 0. Fixes a crash when destroying the CXXConstructExpr.
>
> Modified:
>    cfe/trunk/lib/AST/ExprCXX.cpp
>    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>    cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
>
> Modified: cfe/trunk/lib/AST/ExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=81096&r1=81095&r2=81096&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprCXX.cpp (original)
> +++ cfe/trunk/lib/AST/ExprCXX.cpp Sat Sep  5 17:51:06 2009
> @@ -403,6 +403,8 @@
>       Args = new (C) Stmt*[NumArgs];
>       for (unsigned i = 0; i < numargs; ++i)
>         Args[i] = args[i];
> +      for (unsigned i = numargs; i < NumArgs; ++i)
> +        Args[0] = 0;
>     }
>  }
>
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81096&r1=81095&r2=81096&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Sep  5 17:51:06 2009
> @@ -2899,8 +2899,8 @@
>                                         QualType DeclInitType,
>                                         Expr **Exprs, unsigned NumExprs) {
>   OwningExprResult TempResult =
> -    BuildCXXConstructExpr(/*FIXME: ConstructLoc*/ SourceLocation(),
> -                          DeclInitType, Constructor, Exprs, NumExprs);
> +    BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor,
> +                          Exprs, NumExprs);
>   if (TempResult.isInvalid())
>     return true;
>
>
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp?rev=81096&r1=81095&r2=81096&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp Sat Sep  5 17:51:06 2009
> @@ -20,7 +20,7 @@
>  }
>
>  template<typename T> struct F {
> -  F(T t = 10);
> +  F(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
>   void f(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
>  };
>
> @@ -34,6 +34,9 @@
>  void g3(F<int> f, F<struct S> s) {
>   f.f();
>   s.f(); // expected-note{{in instantiation of default function argument expression for 'f<struct S>' required here}}
> +
> +  F<int> f2;
> +  F<S> s2; // expected-note{{in instantiation of default function argument expression for 'F<struct S>' required here}}
>  }
>
>  template<typename T> struct G {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list