1 /* $NetBSD: lex_comment.c,v 1.3 2024/10/04 11:38:03 rillig Exp $ */ 2 # 3 "lex_comment.c" 3 4 /* 5 * Tests for comments, including lint-style comments that 6 * suppress a single diagnostic. 7 */ 8 9 /* lint1-extra-flags: -X 351 -aa */ 10 11 signed char s8; 12 signed long long s64; 13 14 // A "LINTED" comment suppresses a single warning until the end of the next 15 // statement. 16 void 17 lint_comment(void) 18 { 19 /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ 20 s8 = s64; 21 22 /* LINTED 132 */ 23 s8 = s64; 24 25 /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ 26 s8 = s64; 27 28 /* LINTED 132 "comment" */ 29 s8 = s64; 30 31 /* LINTED 132 */ 32 { 33 } 34 /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ 35 s8 = s64; 36 37 /* LINTED 132 */ 38 { 39 s8 = s64; 40 } 41 /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ 42 s8 = s64; 43 44 if (s8 == 0) 45 ; 46 /* LINTED 132 */ 47 s8 = s64; 48 49 if (s8 == 0) { 50 } 51 /* LINTED 132 */ 52 s8 = s64; 53 54 if (s8 == 0) 55 ; 56 else 57 ; 58 /* LINTED 132 */ 59 s8 = s64; 60 61 if (s8 == 0) { 62 } else { 63 } 64 /* LINTED 132 */ 65 s8 = s64; 66 67 if (s8 == 0) { 68 } else if (s8 == 1) 69 ; 70 /* LINTED 132 */ 71 s8 = s64; 72 73 if (s8 == 0) { 74 } else if (s8 == 1) { 75 } 76 /* LINTED 132 */ 77 s8 = s64; 78 } 79 80 81 /* 82 * Before lex.c 1.41 from 2021-06-19, lint ran into an endless loop when it 83 * saw an unclosed comment at the end of the translation unit. In practice 84 * this was not relevant since the translation unit always comes from the C 85 * preprocessor, which always emits a well-formed token sequence. 86 */ 87 88 /* expect+2: error: unterminated comment [256] */ 89 /* unclosed comment 90