Skip to content

Commit 11a9e09

Browse files
committed
Ensure __LINE__ is expanded
We previously generated several declarations with the same name, because the C preprocessor does not expand __LINE__ after a concatenation operator. Add two levels of indirection to achieve this. Using declarations with the same name was kind of ok for the C front-end, but is a bug with any C++ front-end.
1 parent 65e6b6a commit 11a9e09

File tree

47 files changed

+229
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+229
-89
lines changed

regression/ansi-c/Struct_Bitfields1/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1];
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
struct S1
58
{

regression/ansi-c/Struct_Enum_Padding1/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
#include <inttypes.h>
44

5-
#define STATIC_ASSERT(condition) \
6-
int some_array##__LINE__[(condition) ? 1 : -1]
5+
# define CONCAT(a, b) a##b
6+
# define CONCAT2(a, b) CONCAT(a, b)
7+
8+
# define STATIC_ASSERT(condition) \
9+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
710

811
// Debian package openvswitch
912
enum __attribute__((__packed__)) ofpact_type {

regression/ansi-c/Struct_Initialization1/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
struct A {
58
int x;

regression/ansi-c/Struct_Initialization2/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
struct A {
58
int x;

regression/ansi-c/Struct_Padding2/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
enum {
58
RTAX_UNSPEC,

regression/ansi-c/Struct_Padding3/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
#ifndef __GNUC__
58
#define __builtin_offsetof(a, b) ((unsigned long long)&(((a *)0)->b))

regression/ansi-c/Struct_Padding4/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
struct Z1
58
{

regression/ansi-c/Struct_Padding5/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
#ifdef _MSC_VER
58

regression/ansi-c/Struct_Padding6/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
#pragma pack(4)
58

regression/ansi-c/Union_Padding1/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#define STATIC_ASSERT(condition) \
2-
int some_array##__LINE__[(condition) ? 1 : -1]
1+
#define CONCAT(a, b) a##b
2+
#define CONCAT2(a, b) CONCAT(a, b)
3+
4+
#define STATIC_ASSERT(condition) \
5+
int CONCAT2(some_array, __LINE__)[(condition) ? 1 : -1]
36

47
#ifdef _MSC_VER
58

0 commit comments

Comments
 (0)