-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix default-only switch statements (#324)
This PR fixes a problem in QUIRGenQasm3Visitor that was causing segmentation faults when verifying switch statements that contain only a default region.
- Loading branch information
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
fixes: | ||
- | | ||
Switch statements with only a default region will now correctly compile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
OPENQASM 3.0; | ||
// RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY | ||
// RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm=false| FileCheck %s --match-full-lines --check-prefixes MLIR | ||
// RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm | FileCheck %s --match-full-lines --check-prefixes MLIR | ||
|
||
// | ||
// This code is part of Qiskit. | ||
// | ||
// (C) Copyright IBM 2023, 2024. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
|
||
int i = 15; | ||
qubit $0; | ||
// MLIR: quir.switch %{{.*}}{ | ||
// MLIR-NEXT: }[] | ||
// AST-PRETTY: SwitchStatementNode(SwitchQuantity(name=i, type=ASTTypeIdentifier), | ||
switch (i) { | ||
// AST-PRETTY:statements=[ | ||
// AST-PRETTY:], | ||
// AST-PRETTY:default statement=[ | ||
// AST-PRETTY:]) | ||
default: { | ||
} | ||
break; | ||
} |