diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-09-14 07:05:00 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-09-14 07:05:00 +0000 |
commit | 7eddcff8fa2722bca96e38b7a01c1963e25a49cf (patch) | |
tree | 03d8a69ddc4142bf3c8830f72f51212392b5e377 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 98800d9c3ac013d13fefcf5260068839cbc8881e (diff) | |
download | bcm5719-llvm-7eddcff8fa2722bca96e38b7a01c1963e25a49cf.tar.gz bcm5719-llvm-7eddcff8fa2722bca96e38b7a01c1963e25a49cf.zip |
[Sema] Reject value-initialization of function types
T in the expression T() must be a non-array complete object type or
the void type. Function types are neither.
This fixes PR24798.
llvm-svn: 247535
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index a48e634c3cd..f75ec70cbeb 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1031,6 +1031,11 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, return BuildCXXFunctionalCastExpr(TInfo, LParenLoc, Arg, RParenLoc); } + // C++14 [expr.type.conv]p2: The expression T(), where T is a + // simple-type-specifier or typename-specifier for a non-array complete + // object type or the (possibly cv-qualified) void type, creates a prvalue + // of the specified type, whose value is that produced by value-initializing + // an object of type T. QualType ElemTy = Ty; if (Ty->isArrayType()) { if (!ListInitialization) @@ -1039,6 +1044,10 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, ElemTy = Context.getBaseElementType(Ty); } + if (!ListInitialization && Ty->isFunctionType()) + return ExprError(Diag(TyBeginLoc, diag::err_value_init_for_function_type) + << FullRange); + if (!Ty->isVoidType() && RequireCompleteType(TyBeginLoc, ElemTy, diag::err_invalid_incomplete_type_use, FullRange)) |