Make string and char pointers comparable

This commit is contained in:
2025-02-08 23:02:27 +01:00
parent 8a0f282714
commit d88bd652a4
15 changed files with 425 additions and 123 deletions

View File

@ -648,11 +648,11 @@ namespace boot
template<typename T>
class number_literal : public literal
{
T m_number;
T m_value;
public:
number_literal(const struct position position, const T value)
: literal(position), m_number(value)
number_literal(const struct position position, const T& value)
: literal(position), m_value(value)
{
}
@ -663,7 +663,7 @@ namespace boot
const T& number() const
{
return m_number;
return m_value;
}
};

View File

@ -1,3 +1,20 @@
/* elna-diagnostic.h -- Elna frontend specific diagnostic routines.
Copyright (C) 2025 Free Software Foundation, Inc.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#pragma once
#include "config.h"
@ -14,6 +31,6 @@ namespace gcc
{
location_t get_location(const boot::position *position);
const char *print_type(tree type);
std::string print_type(tree type);
}
}

View File

@ -1,3 +1,20 @@
/* elna-generic.h -- Visitor generating a GENERIC tree.
Copyright (C) 2025 Free Software Foundation, Inc.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#pragma once
#include "elna/boot/ast.h"

View File

@ -1,3 +1,20 @@
/* elna-tree.h -- Utilities to manipulate GCC trees.
Copyright (C) 2025 Free Software Foundation, Inc.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#pragma once
#include <forward_list>
@ -17,6 +34,12 @@ namespace gcc
{
bool is_pointer_type(tree type);
bool is_integral_type(tree type);
/**
* \param lhs Left hand value.
* \param rhs Right hand value.
* \return Whether rhs can be assigned to lhs.
*/
bool are_compatible_pointers(tree lhs, tree rhs);
class tree_chain_base