public inbox for gcc-rust@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Suppress warning in rust-ast-lower-type.h ASTLowerGenericParam.visit.
@ 2021-06-28 21:41 Mark Wielaard
  2021-06-28 22:06 ` Marc
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2021-06-28 21:41 UTC (permalink / raw)
  To: gcc-rust; +Cc: Mark Wielaard

Translating the AST LifetimeType to the HIR LifetimeType causes a warning:
warning: ‘ltt’ may be used uninitialized

Add a default clause to the switch statement calling gcc_unreachable.
This will suppress the warning and make sure that if the AST lifetime type
is invalid or a new unknown type we immediately know when lowering the AST.
---
 gcc/rust/hir/rust-ast-lower-type.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h
index 5e19850e8dd..568a806f98d 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -281,6 +281,8 @@ public:
       case AST::Lifetime::LifetimeType::WILDCARD:
 	ltt = HIR::Lifetime::LifetimeType::WILDCARD;
 	break;
+      default:
+	gcc_unreachable ();
       }
 
     HIR::Lifetime lt (mapping, ltt, param.get_lifetime ().get_lifetime_name (),
-- 
2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-29  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 21:41 [PATCH] Suppress warning in rust-ast-lower-type.h ASTLowerGenericParam.visit Mark Wielaard
2021-06-28 22:06 ` Marc
2021-06-28 22:47   ` Mark Wielaard
2021-06-28 23:41     ` Mark Wielaard
2021-06-29  6:28       ` Marc
2021-06-29  9:10         ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).