Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2114,8 +2114,10 @@ static int getAsInt32(llvm::ConstantInt *C, llvm::Type *I32Ty) {
Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
bool Ignore = TestAndClearIgnoreResultAssign();
(void)Ignore;
assert (Ignore == false && "init list ignored");
unsigned NumInitElements = E->getNumInits();
assert(Ignore == false ||
(NumInitElements == 0 && E->getType()->isVoidType()) &&
"init list ignored");
Comment on lines +2118 to +2120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new assert formulation raises a warning in gcc -Wall: https://godbolt.org/z/G8v1zqE4Y
And the grouping of the comment "init list ignored" to only the second condition seems unintended or misleading. Could we revise this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #158635


// HLSL initialization lists in the AST are an expansion which can contain
// side-effecting expressions wrapped in opaque value expressions. To properly
Expand Down
14 changes: 13 additions & 1 deletion clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s

void f()
{
// CHECK: store i32 0
int i{};
}


namespace GH116440 {
void f() {
void{};
void();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add check-lines to this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you want me to check? noting is emitted

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the function header then CHECK-NEXT: ret void confirms that it actually does nothing/makes it through codegen without going sideways.

So:

// CHECK: define{{.*}} void @{{.*}}GH116440{{.*}}()
// CHECK-NEXT: {{.*}}:
// CHECK-NEXT: ret void

That should work on both windows and itanium manglers, though be more specific on the function name if this test uses a triple.


// CHECK: define{{.*}} void @_ZN8GH1164401fEv()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no target-triple on this test, so this will fail in windows mode. You can try running it with -triple x86_64-windows-pc to see what I mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups!

// CHECK-NEXT: entry
// CHECK-NEXT: ret void
}