[gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] c++: Sorry about type-dependent arg for __builtin_has_attribute [PR90915]

Tamar Christina tnfchris@gcc.gnu.org
Fri Jul 17 15:12:04 GMT 2020


https://gcc.gnu.org/g:53e91f867bd1c3773d37b2efb8875b8b1416a9d2

commit 53e91f867bd1c3773d37b2efb8875b8b1416a9d2
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jun 11 16:21:18 2020 -0400

    c++: Sorry about type-dependent arg for __builtin_has_attribute [PR90915]
    
    Until 92104 is fixed, let's sorry rather than crash.
    
            PR c++/90915
            * parser.c (cp_parser_has_attribute_expression): Sorry on a
            type-dependent argument.
    
            * g++.dg/ext/builtin-has-attribute.C: New test.

Diff:
---
 gcc/cp/parser.c                                  | 7 ++++++-
 gcc/testsuite/g++.dg/ext/builtin-has-attribute.C | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 42d7b1c0336..45ad2c05288 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8677,7 +8677,12 @@ cp_parser_has_attribute_expression (cp_parser *parser)
   location_t atloc = cp_lexer_peek_token (parser->lexer)->location;
   if (tree attr = cp_parser_gnu_attribute_list (parser, /*exactly_one=*/true))
     {
-      if (oper != error_mark_node)
+      if (oper == error_mark_node)
+	/* Nothing.  */;
+      else if (type_dependent_expression_p (oper))
+	sorry_at (atloc, "%<__builtin_has_attribute%> with dependent argument "
+		  "not supported yet");
+      else
 	{
 	  /* Fold constant expressions used in attributes first.  */
 	  cp_check_const_attributes (attr);
diff --git a/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C b/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C
new file mode 100644
index 00000000000..3438dd59ba3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C
@@ -0,0 +1,8 @@
+// PR c++/90915
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+void foo ()
+{
+  static_assert(!__builtin_has_attribute(T::a, aligned), ""); // { dg-message "sorry, unimplemented: .__builtin_has_attribute. with dependent argument not supported yet" }
+}


More information about the Gcc-cvs mailing list