public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8577] gccrs: Add async const function ast validation pass
@ 2024-01-30 11:58 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-30 11:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:04b3089a47c5ccfb86b29a9c64157d5d4f755c1c

commit r14-8577-g04b3089a47c5ccfb86b29a9c64157d5d4f755c1c
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Nov 22 10:44:08 2023 +0100

    gccrs: Add async const function ast validation pass
    
    Add a check during AST validation pass to ensure functions are either
    const or async but not both.
    
    gcc/rust/ChangeLog:
    
            * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
            async const check.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/checks/errors/rust-ast-validation.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index 4b209908f9e5..54276e8fd599 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -98,6 +98,11 @@ ASTValidation::visit (AST::Function &function)
   std::set<Context> valid_context
     = {Context::INHERENT_IMPL, Context::TRAIT_IMPL};
 
+  const auto &qualifiers = function.get_qualifiers ();
+  if (qualifiers.is_async () && qualifiers.is_const ())
+    rust_error_at (function.get_locus (),
+		   "functions cannot be both %<const%> and %<async%>");
+
   if (valid_context.find (context.back ()) == valid_context.end ()
       && function.has_self_param ())
     rust_error_at (

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-30 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 11:58 [gcc r14-8577] gccrs: Add async const function ast validation pass Arthur Cohen

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).