Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: fix support for __alignof__, add s...



details:   https://anonhg.NetBSD.org/src/rev/9599b208c244
branches:  trunk
changeset: 366050:9599b208c244
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu May 12 00:18:35 2022 +0000

description:
lint: fix support for __alignof__, add support for __alignof

Broken since lex.c 1.129 from yesterday.

diffstat:

 tests/usr.bin/xlint/lint1/d_alignof.c   |  12 +++++-------
 tests/usr.bin/xlint/lint1/d_alignof.exp |  20 ++++++++++----------
 tests/usr.bin/xlint/lint1/msg_014.c     |   6 ++----
 tests/usr.bin/xlint/lint1/msg_014.exp   |   9 ++++-----
 usr.bin/xlint/lint1/lex.c               |   6 +++---
 5 files changed, 24 insertions(+), 29 deletions(-)

diffs (134 lines):

diff -r bf09cc158dd5 -r 9599b208c244 tests/usr.bin/xlint/lint1/d_alignof.c
--- a/tests/usr.bin/xlint/lint1/d_alignof.c     Thu May 12 00:09:44 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_alignof.c     Thu May 12 00:18:35 2022 +0000
@@ -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 @@
 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 @@
 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;
 }
diff -r bf09cc158dd5 -r 9599b208c244 tests/usr.bin/xlint/lint1/d_alignof.exp
--- a/tests/usr.bin/xlint/lint1/d_alignof.exp   Thu May 12 00:09:44 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_alignof.exp   Thu May 12 00:18:35 2022 +0000
@@ -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]
diff -r bf09cc158dd5 -r 9599b208c244 tests/usr.bin/xlint/lint1/msg_014.c
--- a/tests/usr.bin/xlint/lint1/msg_014.c       Thu May 12 00:09:44 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_014.c       Thu May 12 00:18:35 2022 +0000
@@ -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 {
diff -r bf09cc158dd5 -r 9599b208c244 tests/usr.bin/xlint/lint1/msg_014.exp
--- a/tests/usr.bin/xlint/lint1/msg_014.exp     Thu May 12 00:09:44 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_014.exp     Thu May 12 00:18:35 2022 +0000
@@ -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]
diff -r bf09cc158dd5 -r 9599b208c244 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Thu May 12 00:09:44 2022 +0000
+++ b/usr.bin/xlint/lint1/lex.c Thu May 12 00:18:35 2022 +0000
@@ -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 @@
 } 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),



Home | Main Index | Thread Index | Old Index