[07/11] Add invariant to enum_type_decl::set_is_declaration_only

Message ID 20200610115940.26035-8-gprocida@google.com
State Committed
Headers
Series Add incomplete enum support. |

Commit Message

Giuliano Procida June 10, 2020, 11:59 a.m. UTC
  From: Dodji Seketeli <dodji@redhat.com>

A declaration-only enum can't have enumerators, so let's enact that
invariant.

	* src/abg-ir.cc (enum_type_decl::set_is_declaration_only): assert
	that a declaration-only enum can't have enumerator.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-ir.cc | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Dodji Seketeli July 6, 2020, 11:15 a.m. UTC | #1
Giuliano Procida <gprocida@google.com> a écrit:

> From: Dodji Seketeli <dodji@redhat.com>
>
> A declaration-only enum can't have enumerators, so let's enact that
> invariant.
>
> 	* src/abg-ir.cc (enum_type_decl::set_is_declaration_only): assert
> 	that a declaration-only enum can't have enumerator.

This patch becomes useless as the decl-only-ness is now a property of
decl_base.

So, I am dropping it from the set.

Cheers,
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 9f4890e8..4aaf3cca 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -15228,6 +15228,10 @@  enum_type_decl::set_is_declaration_only(bool f)
 	else
 	  ABG_ASSERT_NOT_REACHED;
       }
+
+  // A decl-only enum can't have enumerators.
+  if (priv_->is_declaration_only_ && !get_enumerators().empty())
+    ABG_ASSERT_NOT_REACHED;
 }
 
 /// Get the pretty representation of the current instance of @ref