Module Name: src Committed By: rillig Date: Thu May 12 00:18:35 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: d_alignof.c d_alignof.exp msg_014.c msg_014.exp src/usr.bin/xlint/lint1: lex.c Log Message: lint: fix support for __alignof__, add support for __alignof Broken since lex.c 1.129 from yesterday. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_alignof.c cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_alignof.exp cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_014.c \ src/tests/usr.bin/xlint/lint1/msg_014.exp cvs rdiff -u -r1.129 -r1.130 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/d_alignof.c diff -u src/tests/usr.bin/xlint/lint1/d_alignof.c:1.3 src/tests/usr.bin/xlint/lint1/d_alignof.c:1.4 --- src/tests/usr.bin/xlint/lint1/d_alignof.c:1.3 Thu May 12 00:09:44 2022 +++ src/tests/usr.bin/xlint/lint1/d_alignof.c Thu May 12 00:18:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: d_alignof.c,v 1.3 2022/05/12 00:09:44 rillig Exp $ */ +/* $NetBSD: d_alignof.c,v 1.4 2022/05/12 00:18:35 rillig Exp $ */ # 3 "d_alignof.c" /* https://gcc.gnu.org/onlinedocs/gcc/Alignment.html */ @@ -6,12 +6,8 @@ unsigned long leading_and_trailing_alignof_type(void) { - /* FIXME: '__alignof__' must be recognized. */ - /* expect+2: error: function '__alignof__' implicitly declared to return int [215] */ - /* expect+1: error: syntax error 'short' [249] */ return __alignof__(short); } -/* expect-1: warning: function leading_and_trailing_alignof_type falls off bottom without returning value [217] */ unsigned long leading_alignof_type(void) @@ -23,16 +19,17 @@ unsigned long plain_alignof_type(void) { /* The plain word 'alignof' is not recognized by GCC. */ - /* FIXME: plain 'alignof' is not defined by GCC. */ + /* expect+2: error: function 'alignof' implicitly declared to return int [215] */ + /* expect+1: error: syntax error 'short' [249] */ return alignof(short); } +/* expect-1: warning: function plain_alignof_type falls off bottom without returning value [217] */ unsigned long leading_and_trailing_alignof_expr(void) { /* FIXME: '__alignof__' must be recognized. */ /* FIXME: '__alignof__ expr' must be recognized. */ - /* expect+2: error: '__alignof__' undefined [99] */ /* expect+1: error: syntax error '3' [249] */ return __alignof__ 3; } @@ -51,6 +48,7 @@ unsigned long plain_alignof_expr(void) { /* The plain word 'alignof' is not recognized by GCC. */ + /* expect+2: error: 'alignof' undefined [99] */ /* expect+1: error: syntax error '3' [249] */ return alignof 3; } Index: src/tests/usr.bin/xlint/lint1/d_alignof.exp diff -u src/tests/usr.bin/xlint/lint1/d_alignof.exp:1.1 src/tests/usr.bin/xlint/lint1/d_alignof.exp:1.2 --- src/tests/usr.bin/xlint/lint1/d_alignof.exp:1.1 Thu May 12 00:09:44 2022 +++ src/tests/usr.bin/xlint/lint1/d_alignof.exp Thu May 12 00:18:35 2022 @@ -1,10 +1,10 @@ -d_alignof.c(12): error: function '__alignof__' implicitly declared to return int [215] -d_alignof.c(12): error: syntax error 'short' [249] -d_alignof.c(13): warning: function leading_and_trailing_alignof_type falls off bottom without returning value [217] -d_alignof.c(37): error: '__alignof__' undefined [99] -d_alignof.c(37): error: syntax error '3' [249] -d_alignof.c(38): warning: function leading_and_trailing_alignof_expr falls off bottom without returning value [217] -d_alignof.c(46): error: syntax error '3' [249] -d_alignof.c(47): warning: function leading_alignof_expr falls off bottom without returning value [217] -d_alignof.c(55): error: syntax error '3' [249] -d_alignof.c(56): warning: function plain_alignof_expr falls off bottom without returning value [217] +d_alignof.c(24): error: function 'alignof' implicitly declared to return int [215] +d_alignof.c(24): error: syntax error 'short' [249] +d_alignof.c(25): warning: function plain_alignof_type falls off bottom without returning value [217] +d_alignof.c(34): error: syntax error '3' [249] +d_alignof.c(35): warning: function leading_and_trailing_alignof_expr falls off bottom without returning value [217] +d_alignof.c(43): error: syntax error '3' [249] +d_alignof.c(44): warning: function leading_alignof_expr falls off bottom without returning value [217] +d_alignof.c(53): error: 'alignof' undefined [99] +d_alignof.c(53): error: syntax error '3' [249] +d_alignof.c(54): warning: function plain_alignof_expr falls off bottom without returning value [217] Index: src/tests/usr.bin/xlint/lint1/msg_014.c diff -u src/tests/usr.bin/xlint/lint1/msg_014.c:1.6 src/tests/usr.bin/xlint/lint1/msg_014.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_014.c:1.6 Thu May 12 00:09:44 2022 +++ src/tests/usr.bin/xlint/lint1/msg_014.c Thu May 12 00:18:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_014.c,v 1.6 2022/05/12 00:09:44 rillig Exp $ */ +/* $NetBSD: msg_014.c,v 1.7 2022/05/12 00:18:35 rillig Exp $ */ # 3 "msg_014.c" // Test for message: compiler takes alignment of function [14] @@ -6,9 +6,7 @@ typedef void function(void); -/* FIXME: '__alignof__' must be recognized. */ -/* expect+2: error: function '__alignof__' implicitly declared to return int [215] */ -/* expect+1: error: syntax error 'function' [249] */ +/* expect+1: error: cannot take size/alignment of function type 'function(void) returning void' [144] */ unsigned long alignof_function = __alignof__(function); struct illegal_bit_field { Index: src/tests/usr.bin/xlint/lint1/msg_014.exp diff -u src/tests/usr.bin/xlint/lint1/msg_014.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_014.exp:1.7 --- src/tests/usr.bin/xlint/lint1/msg_014.exp:1.6 Thu May 12 00:09:44 2022 +++ src/tests/usr.bin/xlint/lint1/msg_014.exp Thu May 12 00:18:35 2022 @@ -1,5 +1,4 @@ -msg_014.c(12): error: function '__alignof__' implicitly declared to return int [215] -msg_014.c(12): error: syntax error 'function' [249] -msg_014.c(16): warning: illegal bit-field type 'function(void) returning void' [35] -msg_014.c(18): error: function illegal in structure or union [38] -msg_014.c(23): error: array of function is illegal [16] +msg_014.c(10): error: cannot take size/alignment of function type 'function(void) returning void' [144] +msg_014.c(14): warning: illegal bit-field type 'function(void) returning void' [35] +msg_014.c(16): error: function illegal in structure or union [38] +msg_014.c(21): error: array of function is illegal [16] Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.129 src/usr.bin/xlint/lint1/lex.c:1.130 --- src/usr.bin/xlint/lint1/lex.c:1.129 Wed May 11 15:46:25 2022 +++ src/usr.bin/xlint/lint1/lex.c Thu May 12 00:18:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.129 2022/05/11 15:46:25 christos Exp $ */ +/* $NetBSD: lex.c,v 1.130 2022/05/12 00:18:35 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.129 2022/05/11 15:46:25 christos Exp $"); +__RCSID("$NetBSD: lex.c,v 1.130 2022/05/12 00:18:35 rillig Exp $"); #endif #include <ctype.h> @@ -114,7 +114,7 @@ static const struct keyword { } keywords[] = { kwdef_keyword( "_Alignas", T_ALIGNAS), kwdef_keyword( "_Alignof", T_ALIGNOF), - kwdef_token( "alignof", T_ALIGNOF, 78,0,3), + kwdef_token( "alignof", T_ALIGNOF, 78,0,6), kwdef_token( "asm", T_ASM, 78,1,7), kwdef_token( "attribute", T_ATTRIBUTE, 78,1,6), kwdef_sclass( "auto", AUTO, 78,0,1),