* [c-family] Small fix for -fdump-ada-spec
@ 2023-01-13 21:16 Eric Botcazou
0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2023-01-13 21:16 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 349 bytes --]
This is needed to support the _Float32 and _Float64 types.
Tested on x86-64/Linux, applied on the mainline.
2023-01-13 Eric Botcazou <ebotcazou@adacore.com>
c-family/
* c-ada-spec.cc (is_float32): New function.
(is_float64): Likewise.
(is_float128): Tweak.
(dump_ada_node) <REAL_TYPE>: Call them to recognize more types.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2038 bytes --]
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index faf71742522..1e011d52825 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -2030,7 +2030,39 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, int spc)
}
}
-/* Return true if NODE is the __float128/_Float128 type. */
+/* Return true if NODE is the _Float32/_Float32x type. */
+
+static bool
+is_float32 (tree node)
+{
+ if (!TYPE_NAME (node) || TREE_CODE (TYPE_NAME (node)) != TYPE_DECL)
+ return false;
+
+ tree name = DECL_NAME (TYPE_NAME (node));
+
+ if (IDENTIFIER_POINTER (name) [0] != '_')
+ return false;
+
+ return id_equal (name, "_Float32") || id_equal (name, "_Float32x");
+}
+
+/* Return true if NODE is the _Float64/_Float64x type. */
+
+static bool
+is_float64 (tree node)
+{
+ if (!TYPE_NAME (node) || TREE_CODE (TYPE_NAME (node)) != TYPE_DECL)
+ return false;
+
+ tree name = DECL_NAME (TYPE_NAME (node));
+
+ if (IDENTIFIER_POINTER (name) [0] != '_')
+ return false;
+
+ return id_equal (name, "_Float64") || id_equal (name, "_Float64x");
+}
+
+/* Return true if NODE is the __float128/_Float128/_Float128x type. */
static bool
is_float128 (tree node)
@@ -2043,7 +2075,9 @@ is_float128 (tree node)
if (IDENTIFIER_POINTER (name) [0] != '_')
return false;
- return id_equal (name, "__float128") || id_equal (name, "_Float128");
+ return id_equal (name, "__float128")
+ || id_equal (name, "_Float128")
+ || id_equal (name, "_Float128x");
}
static bool bitfield_used = false;
@@ -2132,7 +2166,17 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
break;
case REAL_TYPE:
- if (is_float128 (node))
+ if (is_float32 (node))
+ {
+ pp_string (buffer, "Float");
+ break;
+ }
+ else if (is_float64 (node))
+ {
+ pp_string (buffer, "Long_Float");
+ break;
+ }
+ else if (is_float128 (node))
{
append_withs ("Interfaces.C.Extensions", false);
pp_string (buffer, "Extensions.Float_128");
^ permalink raw reply [flat|nested] 3+ messages in thread
* [c-family] Small fix for -fdump-ada-spec
@ 2018-10-01 9:39 Eric Botcazou
0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2018-10-01 9:39 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 312 bytes --]
The translation of a pointer to constant value was lacking the package prefix.
Tested on x86_64-suse-linux, applied on the mainline.
2018-10-01 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (get_underlying_decl): Get to the main type variant.
(dump_ada_node): Add const keyword.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1136 bytes --]
Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c (revision 264732)
+++ c-ada-spec.c (working copy)
@@ -1020,13 +1020,18 @@ get_underlying_decl (tree type)
if (DECL_P (type))
return type;
- /* type is a typedef. */
- if (TYPE_P (type) && TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
- return TYPE_NAME (type);
-
- /* TYPE_STUB_DECL has been set for type. */
- if (TYPE_P (type) && TYPE_STUB_DECL (type))
- return TYPE_STUB_DECL (type);
+ if (TYPE_P (type))
+ {
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* type is a typedef. */
+ if (TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
+ return TYPE_NAME (type);
+
+ /* TYPE_STUB_DECL has been set for type. */
+ if (TYPE_STUB_DECL (type))
+ return TYPE_STUB_DECL (type);
+ }
return NULL_TREE;
}
@@ -2143,8 +2148,8 @@ dump_ada_node (pretty_printer *buffer, t
}
else
{
+ const unsigned int quals = TYPE_QUALS (TREE_TYPE (node));
bool is_access = false;
- unsigned int quals = TYPE_QUALS (TREE_TYPE (node));
if (VOID_TYPE_P (TREE_TYPE (node)))
{
^ permalink raw reply [flat|nested] 3+ messages in thread
* [c-family] Small fix for -fdump-ada-spec
@ 2012-10-18 19:26 Eric Botcazou
0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2012-10-18 19:26 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 378 bytes --]
The recent introduction of virtual locations revealed a weak spot in the
implementation of -fdump-ada-spec.
Tested on x86_64-suse-linux, applied on the mainline as obvious.
2012-10-18 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (LOCATION_COL): Delete.
(compare_location): New function.
(compare_node): Use it.
(compare_comment): Likewise.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2160 bytes --]
Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c (revision 192526)
+++ c-ada-spec.c (working copy)
@@ -67,8 +67,6 @@ static void dump_ads (const char *, void
static char *to_ada_name (const char *, int *);
static bool separate_class_package (tree);
-#define LOCATION_COL(LOC) ((expand_location (LOC)).column)
-
#define INDENT(SPACE) do { \
int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
@@ -553,6 +551,26 @@ decl_sloc (const_tree decl, bool last)
return decl_sloc_common (decl, last, false);
}
+/* Compare two locations LHS and RHS. */
+
+static int
+compare_location (location_t lhs, location_t rhs)
+{
+ expanded_location xlhs = expand_location (lhs);
+ expanded_location xrhs = expand_location (rhs);
+
+ if (xlhs.file != xrhs.file)
+ return filename_cmp (xlhs.file, xrhs.file);
+
+ if (xlhs.line != xrhs.line)
+ return xlhs.line - xrhs.line;
+
+ if (xlhs.column != xrhs.column)
+ return xlhs.column - xrhs.column;
+
+ return 0;
+}
+
/* Compare two declarations (LP and RP) by their source location. */
static int
@@ -561,7 +579,7 @@ compare_node (const void *lp, const void
const_tree lhs = *((const tree *) lp);
const_tree rhs = *((const tree *) rp);
- return decl_sloc (lhs, true) - decl_sloc (rhs, true);
+ return compare_location (decl_sloc (lhs, true), decl_sloc (rhs, true));
}
/* Compare two comments (LP and RP) by their source location. */
@@ -572,17 +590,7 @@ compare_comment (const void *lp, const v
const cpp_comment *lhs = (const cpp_comment *) lp;
const cpp_comment *rhs = (const cpp_comment *) rp;
- if (LOCATION_FILE (lhs->sloc) != LOCATION_FILE (rhs->sloc))
- return filename_cmp (LOCATION_FILE (lhs->sloc),
- LOCATION_FILE (rhs->sloc));
-
- if (LOCATION_LINE (lhs->sloc) != LOCATION_LINE (rhs->sloc))
- return LOCATION_LINE (lhs->sloc) - LOCATION_LINE (rhs->sloc);
-
- if (LOCATION_COL (lhs->sloc) != LOCATION_COL (rhs->sloc))
- return LOCATION_COL (lhs->sloc) - LOCATION_COL (rhs->sloc);
-
- return 0;
+ return compare_location (lhs->sloc, rhs->sloc);
}
static tree *to_dump = NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-13 21:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 21:16 [c-family] Small fix for -fdump-ada-spec Eric Botcazou
-- strict thread matches above, loose matches on Subject: below --
2018-10-01 9:39 Eric Botcazou
2012-10-18 19:26 Eric Botcazou
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).