Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++20 [[likely]]/[[unlikely]] case statements erroneously fail to compile in the presence of [[fallthrough]] #48798

Closed
imallett mannequin opened this issue Mar 5, 2021 · 3 comments
Labels
bugzilla Issues migrated from bugzilla duplicate Resolved as duplicate

Comments

@imallett
Copy link
Mannequin

imallett mannequin commented Mar 5, 2021

Bugzilla Link 49454
Resolution DUPLICATE
Resolved on Oct 11, 2021 09:06
Version unspecified
OS All
CC @AaronBallman,@mordante,@nico

Extended Description

See the following complete example:

//Compile with "-std=c++20"
void f(int i) {
	switch (i) {
		[[likely]] case 1:
			[[fallthrough]];
		case 2:
			break;
	}
}

This should compile (and does on every other compiler), but doesn't on Clang. Clang (tested 13.0.0) produces:

<source>:5:13: error: fallthrough annotation does not directly precede switch label
            [[fallthrough]];
            ^

Removing either [[likely]] or [[fallthrough]]; is sufficient to cause the compile to succeed.

@AaronBallman
Copy link
Collaborator

I can confirm that the issue occurs. From some early debugging, it looks like markFallthroughVisited() is never being called, likely because we're not peeking through attributed statements somewhere when comparing against case and label statements.

@nico
Copy link
Contributor

nico commented Oct 11, 2021

My current WIP patch for bug 52103 happens to fix this too, so let's dupe it over.

*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#52103 ***

@nico
Copy link
Contributor

nico commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#52103

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

2 participants