diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-25 13:46:13 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-25 13:46:13 +0000 |
commit | 5653ca5088b799ada71b5043a0a2cd71c727da83 (patch) | |
tree | 994a2da6c69fad46b091a7cdbc3b19513bea5dd4 | |
parent | 293361afd4199c92aabff9267fddea890943c586 (diff) |
If a parameter has a default argument expression, make sure to instantiate the parameter type before checking that the expression is a valid initializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79986 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | test/SemaTemplate/default-expr-arguments.cpp | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index c30b974af9..0dbefe1dd0 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -107,6 +107,12 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg, { QualType ParamType = Param->getType(); + if (RequireCompleteType(Param->getLocation(), Param->getType(), + diag::err_typecheck_decl_incomplete_type)) { + Param->setInvalidDecl(); + return true; + } + Expr *Arg = (Expr *)DefaultArg.get(); // C++ [dcl.fct.default]p5 diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp index 34d2d9d6fe..7c813c9852 100644 --- a/test/SemaTemplate/default-expr-arguments.cpp +++ b/test/SemaTemplate/default-expr-arguments.cpp @@ -26,3 +26,11 @@ template<typename T> struct F { void g2() { F<int> f; } + +template<typename T> struct G { + G(T) {} +}; + +void s(G<int> flags = 10) { } + + |