aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-10-25 07:49:16 +0000
committerIain Sandoe <iain@sandoe.co.uk>2020-11-13 10:39:48 +0000
commit3fe07cdec8c79bce53ea5aeb8e607df6eb5c8c2c (patch)
tree989f0b35f1a61b36a0bfc388398ec51850bf1de3 /gcc/c/c-parser.c
parent4852c3266ec0887316b9fbbb106b8540e3e948d6 (diff)
downloadgcc-3fe07cdec8c79bce53ea5aeb8e607df6eb5c8c2c.zip
gcc-3fe07cdec8c79bce53ea5aeb8e607df6eb5c8c2c.tar.gz
gcc-3fe07cdec8c79bce53ea5aeb8e607df6eb5c8c2c.tar.bz2
C-family, Objective-C [1/3] : Implement Wobjc-root-class [PR77404].
This warning catches the case that the user has left the superclass specification from a class interface. Root classes are, of course, permitted and an attribute is added to mark these so that the diagnostic is suppressed. The warning and attribute spellings have been kept in sync with the language reference implementation (clang). The diagnostic location information present in the objective-c interface and class definitions is relatively poor. This patch adds a location for the class name to the interface and makes use of it in existing warnings. Part 1 is the changes to code and added tests. Many entries in the testsuite make use of root classes so there are a large number of mechanical changes there adding "-Wno-objc-root-class" to the options. The test changes are parts 2 (objective-c) and 3 (objective-c++) in the patch series. gcc/c-family/ChangeLog: PR objc/77404 * c-attribs.c (handle_objc_root_class_attribute): New * c-objc.h (objc_start_class_interface): Add a location value for the position of the class name. * c.opt: Add Wobjc-root-class. * stub-objc.c (objc_start_class_interface): Add a location value for the position of the class name. gcc/c/ChangeLog: PR objc/77404 * c-parser.c (c_parser_objc_class_definition): Pass the location of the class name to the interface declaration. gcc/cp/ChangeLog: PR objc/77404 * parser.c (cp_parser_objc_class_interface): Pass the location of the class name to the interface declaration. gcc/objc/ChangeLog: PR objc/77404 * objc-act.c (objc_start_class_interface): Accept the location of the class name, use it in existing diagnostic. (start_class): Accept obj_root_class type attributes. Warn when the interface for an implementation does not contain a super class (unless the diagnostic is suppressed by the the command line flag or the objc_root_class type attribute). gcc/testsuite/ChangeLog: PR objc/77404 * objc.dg/attributes/root-class-01.m: New test. * objc.dg/root-class-00.m: New test. * obj-c++.dg/attributes/root-class-01.mm: New test. * obj-c++.dg/root-class-00.mm: New test. gcc/ChangeLog: PR objc/77404 * doc/extend.texi: Document the objc_root_class attribute. * doc/invoke.texi: Document -Wobjc-root-class.
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 377914c..f4c4cf7 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -10801,6 +10801,7 @@ c_parser_objc_class_definition (c_parser *parser, tree attributes)
return;
}
id1 = c_parser_peek_token (parser)->value;
+ location_t loc1 = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
{
@@ -10860,7 +10861,7 @@ c_parser_objc_class_definition (c_parser *parser, tree attributes)
tree proto = NULL_TREE;
if (c_parser_next_token_is (parser, CPP_LESS))
proto = c_parser_objc_protocol_refs (parser);
- objc_start_class_interface (id1, superclass, proto, attributes);
+ objc_start_class_interface (id1, loc1, superclass, proto, attributes);
}
else
objc_start_class_implementation (id1, superclass);