Skip to content

Commit d42bca2

Browse files
authored
Remove default warning on switch statement. (#30)
Qiskit does not generate the default, nor is it required by the OQ3 spec. This warning has been polluting our error diagnostics for users.
1 parent 0dd5e42 commit d42bca2

File tree

1 file changed

+6
-42
lines changed

1 file changed

+6
-42
lines changed

lib/AST/ASTFunctions.cpp

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
698698
}
699699

700700
const ASTDefaultStatementNode *DSN = SWS->GetDefaultStatement();
701-
if (!DSN) {
702-
std::stringstream M;
703-
M << "Switch statement without a default label.";
704-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
705-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
706-
DiagLevel::Warning);
707-
} else {
701+
if (DSN) {
708702
const ASTStatementList *DSL = DSN->GetStatementList();
709703
assert(DSL && "Could not obtain a valid ASTStatementList!");
710704

@@ -849,13 +843,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
849843
}
850844

851845
const ASTDefaultStatementNode *DSN = SWS->GetDefaultStatement();
852-
if (!DSN) {
853-
std::stringstream M;
854-
M << "Switch statement without a default label.";
855-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
856-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
857-
DiagLevel::Warning);
858-
} else {
846+
if (DSN) {
859847
const ASTStatementList *DSL = DSN->GetStatementList();
860848
assert(DSL && "Could not obtain a valid ASTStatementList!");
861849

@@ -1000,13 +988,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
1000988
}
1001989

1002990
const ASTDefaultStatementNode *DSN = SWS->GetDefaultStatement();
1003-
if (!DSN) {
1004-
std::stringstream M;
1005-
M << "Switch statement without a default label.";
1006-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
1007-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
1008-
DiagLevel::Warning);
1009-
} else {
991+
if (DSN) {
1010992
const ASTStatementList *DSL = DSN->GetStatementList();
1011993
assert(DSL && "Could not obtain a valid ASTStatementList!");
1012994

@@ -1153,13 +1135,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
11531135

11541136
const ASTDefaultStatementNode *DSN =
11551137
SWS->GetDefaultStatement();
1156-
if (!DSN) {
1157-
std::stringstream M;
1158-
M << "Switch statement without a default label.";
1159-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
1160-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
1161-
DiagLevel::Warning);
1162-
} else {
1138+
if (DSN) {
11631139
const ASTStatementList *DSL = DSN->GetStatementList();
11641140
assert(DSL && "Could not obtain a valid ASTStatementList!");
11651141

@@ -1306,13 +1282,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
13061282

13071283
const ASTDefaultStatementNode *DSN =
13081284
SWS->GetDefaultStatement();
1309-
if (!DSN) {
1310-
std::stringstream M;
1311-
M << "Switch statement without a default label.";
1312-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
1313-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
1314-
DiagLevel::Warning);
1315-
} else {
1285+
if (DSN) {
13161286
const ASTStatementList *DSL = DSN->GetStatementList();
13171287
assert(DSL && "Could not obtain a valid ASTStatementList!");
13181288

@@ -1459,13 +1429,7 @@ const ASTReturnStatementNode *ASTFunctionDefinitionNode::CheckReturnStatements(
14591429

14601430
const ASTDefaultStatementNode *DSN =
14611431
SWS->GetDefaultStatement();
1462-
if (!DSN) {
1463-
std::stringstream M;
1464-
M << "Switch statement without a default label.";
1465-
QasmDiagnosticEmitter::Instance().EmitDiagnostic(
1466-
DIAGLineCounter::Instance().GetLocation(SWS), M.str(),
1467-
DiagLevel::Warning);
1468-
} else {
1432+
if (DSN) {
14691433
const ASTStatementList *DSL = DSN->GetStatementList();
14701434
assert(DSL && "Could not obtain a valid ASTStatementList!");
14711435

0 commit comments

Comments
 (0)