aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-17 17:57:40 +0200
committerEugen Wissner <belka@caraus.de>2026-07-17 17:57:40 +0200
commit349e84c693c1444606e877f4d8cdc1a39aa91634 (patch)
treecd382dbac860cf8e78b8725a1c9b6ce9bc1fcd32 /boot
parent4f260c5e98def6bd1b3498d4085de5080cca7641 (diff)
downloadelna-349e84c693c1444606e877f4d8cdc1a39aa91634.tar.gz
Reject const in const nesting
Diffstat (limited to 'boot')
-rw-r--r--boot/name_analysis.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/boot/name_analysis.cc b/boot/name_analysis.cc
index 48251cd..5255878 100644
--- a/boot/name_analysis.cc
+++ b/boot/name_analysis.cc
@@ -70,6 +70,16 @@ namespace elna::boot
return "const must be written before the array size, not after";
}
+ double_const_error::double_const_error(const source_position position)
+ : error(position)
+ {
+ }
+
+ std::string double_const_error::what() const
+ {
+ return "Duplicate 'const' qualifier is not allowed";
+ }
+
// Members of a constant aggregate are constant themselves.
static type qualify_member_type(const type& element, const type& aggregate)
{
@@ -179,6 +189,11 @@ namespace elna::boot
void name_analysis_visitor::visit(constant_type_expression *expression)
{
walking_visitor::visit(expression);
+
+ if (this->current_type.get<constant_type>() != nullptr)
+ {
+ add_error<double_const_error>(expression->position());
+ }
this->current_type = type(std::make_shared<constant_type>(this->current_type));
}