Sat Jul 10 20:58:35 2021 UTC ()
lint: move type_attribute back into the main section

Type attributes are a standard feature since C11 and thus do not belong
in the GCC-specific section.  Only the GCC __attribute__ belongs there.

No functional change.


(rillig)
diff -r1.301 -r1.302 src/usr.bin/xlint/lint1/cgram.y

cvs diff -r1.301 -r1.302 src/usr.bin/xlint/lint1/cgram.y (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/10 20:44:23 1.301
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/10 20:58:35 1.302
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.301 2021/07/10 20:44:23 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.302 2021/07/10 20:58:35 rillig Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint) 37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: cgram.y,v 1.301 2021/07/10 20:44:23 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.302 2021/07/10 20:58:35 rillig Exp $");
39#endif 39#endif
40 40
41#include <limits.h> 41#include <limits.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <string.h> 43#include <string.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48 48
49/* 49/*
50 * Contains the level of current declaration, used for symbol table entries. 50 * Contains the level of current declaration, used for symbol table entries.
51 * 0 is the top-level, > 0 is inside a function body. 51 * 0 is the top-level, > 0 is inside a function body.
@@ -553,26 +553,50 @@ declmod: @@ -553,26 +553,50 @@ declmod:
553qualifier_or_storage_class: 553qualifier_or_storage_class:
554 add_type_qualifier 554 add_type_qualifier
555 | T_SCLASS { 555 | T_SCLASS {
556 add_storage_class($1); 556 add_storage_class($1);
557 } 557 }
558 ; 558 ;
559 559
560add_type_specifier: 560add_type_specifier:
561 type_specifier { 561 type_specifier {
562 add_type($1); 562 add_type($1);
563 } 563 }
564 ; 564 ;
565 565
 566type_attribute_list_opt:
 567 /* empty */
 568 | type_attribute_list
 569 ;
 570
 571type_attribute_list:
 572 type_attribute
 573 | type_attribute_list type_attribute
 574 ;
 575
 576type_attribute_opt:
 577 /* empty */
 578 | type_attribute
 579 ;
 580
 581type_attribute: /* See C11 6.7 declaration-specifiers */
 582 gcc_attribute
 583 | T_ALIGNAS T_LPAREN align_as T_RPAREN
 584 | T_PACKED {
 585 addpacked();
 586 }
 587 | T_NORETURN
 588 ;
 589
566type_specifier: /* C99 6.7.2 */ 590type_specifier: /* C99 6.7.2 */
567 notype_type_specifier 591 notype_type_specifier
568 | T_TYPENAME { 592 | T_TYPENAME {
569 $$ = getsym($1)->s_type; 593 $$ = getsym($1)->s_type;
570 } 594 }
571 ; 595 ;
572 596
573add_notype_type_specifier: 597add_notype_type_specifier:
574 notype_type_specifier { 598 notype_type_specifier {
575 add_type($1); 599 add_type($1);
576 } 600 }
577 ; 601 ;
578 602
@@ -1891,50 +1915,26 @@ identifier: /* C99 6.4.2.1 */ @@ -1891,50 +1915,26 @@ identifier: /* C99 6.4.2.1 */
1891 | T_TYPENAME { 1915 | T_TYPENAME {
1892 $$ = $1; 1916 $$ = $1;
1893 cgram_debug("typename '%s'", $$->sb_name); 1917 cgram_debug("typename '%s'", $$->sb_name);
1894 } 1918 }
1895 ; 1919 ;
1896 1920
1897comma_opt: 1921comma_opt:
1898 /* empty */ 1922 /* empty */
1899 | T_COMMA 1923 | T_COMMA
1900 ; 1924 ;
1901 1925
1902/* GCC extensions */ 1926/* GCC extensions */
1903 1927
1904type_attribute_list_opt: 
1905 /* empty */ 
1906 | type_attribute_list 
1907 ; 
1908 
1909type_attribute_list: 
1910 type_attribute 
1911 | type_attribute_list type_attribute 
1912 ; 
1913 
1914type_attribute_opt: 
1915 /* empty */ 
1916 | type_attribute 
1917 ; 
1918 
1919type_attribute: 
1920 gcc_attribute 
1921 | T_ALIGNAS T_LPAREN align_as T_RPAREN 
1922 | T_PACKED { 
1923 addpacked(); 
1924 } 
1925 | T_NORETURN 
1926 ; 
1927 
1928gcc_attribute_list_opt: 1928gcc_attribute_list_opt:
1929 /* empty */ 1929 /* empty */
1930 | gcc_attribute_list 1930 | gcc_attribute_list
1931 ; 1931 ;
1932 1932
1933gcc_attribute_list: 1933gcc_attribute_list:
1934 gcc_attribute 1934 gcc_attribute
1935 | gcc_attribute_list gcc_attribute 1935 | gcc_attribute_list gcc_attribute
1936 ; 1936 ;
1937 1937
1938/* https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html */ 1938/* https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html */
1939gcc_attribute: 1939gcc_attribute:
1940 T_ATTRIBUTE T_LPAREN T_LPAREN { 1940 T_ATTRIBUTE T_LPAREN T_LPAREN {