[pushed] Objective-C++ : Avoid ICE on invalid with empty attributes.

Iain Sandoe iain@sandoe.co.uk
Wed Nov 18 20:43:21 GMT 2020


Hi

Empty prefix attributes like:

__attribute__ (())
@interface MyClass
@end

cause an ICE at present.
Check for that case and skip them.

tested on x86_64-darwin,
pushed to master,
thanks
Iain

gcc/cp/ChangeLog:

	* parser.c (cp_parser_objc_valid_prefix_attributes): Check
	for empty attributes.
---
  gcc/cp/parser.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b7ef259b048..cf4e4aa1b75 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -33992,8 +33992,8 @@ cp_parser_objc_valid_prefix_attributes (cp_parser*  
parser, tree *attrib)
  {
    cp_lexer_save_tokens (parser->lexer);
    tree addon = cp_parser_attributes_opt (parser);
-  gcc_checking_assert (addon);
-  if (OBJC_IS_AT_KEYWORD (cp_lexer_peek_token (parser->lexer)->keyword))
+  if (addon
+      && OBJC_IS_AT_KEYWORD (cp_lexer_peek_token (parser->lexer)->keyword))
      {
        cp_lexer_commit_tokens (parser->lexer);
        if (*attrib)
-- 
2.24.1




More information about the Gcc-patches mailing list