diff --git a/src/cc65/initdata.c b/src/cc65/initdata.c index 82cebefc2..addc7421b 100644 --- a/src/cc65/initdata.c +++ b/src/cc65/initdata.c @@ -302,6 +302,13 @@ static unsigned ParsePointerInit (const Type* T) /* Optional opening brace */ unsigned BraceCount = OpeningCurlyBraces (0); + /* We warn if an initializer for a scalar contains braces, because this is + ** quite unusual and often a sign for some problem in the input. + */ + if (BraceCount > 0) { + Warning ("Braces around scalar initializer"); + } + /* Expression */ ExprDesc ED = NoCodeConstExpr (hie1); TypeConversion (&ED, T); diff --git a/test/ref/bug2134.c b/test/ref/bug2134.c new file mode 100644 index 000000000..9e95e1daa --- /dev/null +++ b/test/ref/bug2134.c @@ -0,0 +1,2 @@ +int i = { 0 }; +char* p = { 0 }; diff --git a/test/ref/bug2134.cref b/test/ref/bug2134.cref new file mode 100644 index 000000000..72bbbad04 --- /dev/null +++ b/test/ref/bug2134.cref @@ -0,0 +1,2 @@ +bug2134.c:1: Warning: Braces around scalar initializer +bug2134.c:2: Warning: Braces around scalar initializer