diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -4749,8 +4749,8 @@ /// @endcode /// /// Prior to semantic analysis, an initializer list will represent the -/// initializer list as written by the user, but will have the -/// placeholder type "void". This initializer list is called the +/// initializer list as written by the user, but will have dependent +/// type as placeholder. This initializer list is called the /// syntactic form of the initializer, and may contain C99 designated /// initializers (represented as DesignatedInitExprs), initializations /// of subobject members without explicit braces, and so on. Clients diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -886,8 +886,7 @@ // is ill-formed. // // Since we've already performed array-to-pointer and function-to-pointer - // decay, the only such type in C++ is cv void. This also handles - // initializer lists as variadic arguments. + // decay, the only such type in C++ is cv void. if (Ty->isVoidType()) return VAK_Invalid; @@ -896,6 +895,10 @@ return VAK_Valid; } + // This covers initializer lists. + if (Ty->isDependentType()) + return VAK_Invalid; + if (Ty.isDestructedType() == QualType::DK_nontrivial_c_struct) return VAK_Invalid; @@ -7155,7 +7158,7 @@ InitListExpr *E = new (Context) InitListExpr(Context, LBraceLoc, InitArgList, RBraceLoc); - E->setType(Context.VoidTy); // FIXME: just a place holder for now. + E->setType(Context.DependentTy); return E; } diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -744,7 +744,7 @@ InitListExpr *OuterILE, unsigned OuterIndex, bool FillWithNoInit) { - assert((ILE->getType() != SemaRef.Context.VoidTy) && + assert((ILE->getType() != SemaRef.Context.DependentTy) && "Should not have void type"); // We don't need to do any checks when just filling NoInitExprs; that can't diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -780,6 +780,9 @@ continue; } + if (isa_and_nonnull(RetE)) + continue; // Should have been diagnosed already, type is bogus. + // FIXME: This is a poor diagnostic for ReturnStmts without expressions. // TODO: It's possible that the *first* return is the divergent one. Diag(RS->getBeginLoc(), diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -607,7 +607,7 @@ // CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-23]]:3, line:[[@LINE-22]]:34> col:14 TestVarTemplate // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 TestVarTemplate 'const T' cinit - // CHECK-NEXT: | `-InitListExpr 0x{{.+}} 'void' + // CHECK-NEXT: | `-InitListExpr 0x{{.+}} '' // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -197,7 +197,7 @@ Bar b3 = Bar(x); // CHECK: `-VarDecl {{.*}} b4 'Bar' // CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar' contains-errors - // CHECK-NEXT: `-InitListExpr {{.*}} 'void' + // CHECK-NEXT: `-InitListExpr {{.*}} '' // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int' Bar b4 = Bar{x}; // CHECK: `-VarDecl {{.*}} b5 'Bar' diff --git a/clang/test/AST/ast-dump-stmt-json.cpp b/clang/test/AST/ast-dump-stmt-json.cpp --- a/clang/test/AST/ast-dump-stmt-json.cpp +++ b/clang/test/AST/ast-dump-stmt-json.cpp @@ -2455,7 +2455,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void" +// CHECK-NEXT: "qualType": "" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue" // CHECK-NEXT: } diff --git a/clang/test/SemaOpenCLCXX/address-space-references.clcpp b/clang/test/SemaOpenCLCXX/address-space-references.clcpp --- a/clang/test/SemaOpenCLCXX/address-space-references.clcpp +++ b/clang/test/SemaOpenCLCXX/address-space-references.clcpp @@ -22,7 +22,7 @@ bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}} C c; c.gen({1, 2}); - c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type 'void' changes address space}} + c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type '' changes address space}} c.nested_list({{1, 2}, {3, 4}}); }