diff mbox series

fix {pp-number} ## ...

Message ID d67f161a-acb5-4cda-a51a-69a4178e9c9f@p183 (mailing list archive)
State New, archived
Headers show
Series fix {pp-number} ## ... | expand

Commit Message

Alexey Dobriyan Feb. 16, 2024, 6:44 p.m. UTC
pp-number token may have arbitrary number of dots after first digit

	pp-number:
		digit
		. digit
		pp-number .

which means that merging any pp-number with ... is valid operation and
should yield pp-number:

	#define M(a,b) a##b
	M(1,...)

should preprocess to

	1...

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 pre-process.c |    3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

--- a/pre-process.c
+++ b/pre-process.c
@@ -482,6 +482,7 @@  static void expand_arguments(int count, struct arg *args)
  *  - number + number -> number
  *  - number + ident -> number
  *  - number + '.' -> number
+ *  - number + '...' -> number
  *  - number + '+' or '-' -> number, if number used to end on [eEpP].
  *  - '.' + number -> number, if number used to start with a digit.
  *  - special + special -> either special or an error.
@@ -524,6 +525,8 @@  static enum token_type combine(struct token *left, struct token *right, char *p)
 			switch (right->special) {
 			case '.':
 				break;
+			case SPECIAL_ELLIPSIS:
+				break;
 			case '+': case '-':
 				if (strchr("eEpP", p[len - 2]))
 					break;