From 5b7145b43052ae933d484cca3ead128ea2ffd15a Mon Sep 17 00:00:00 2001 From: Christian Kaestner Date: Fri, 20 Nov 2015 14:50:25 -0500 Subject: [PATCH] additional check for reinitializing variables checks "const int" especially --- .../GeneratedVarInitializerTests.scala | 2752 ++++++++++++++++- .../VarInitializerTestGenerator.scala | 17 +- 2 files changed, 2604 insertions(+), 165 deletions(-) diff --git a/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generated/GeneratedVarInitializerTests.scala b/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generated/GeneratedVarInitializerTests.scala index f38595324..87d811352 100644 --- a/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generated/GeneratedVarInitializerTests.scala +++ b/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generated/GeneratedVarInitializerTests.scala @@ -1,7 +1,7 @@ package de.fosd.typechef.typesystem.generated -import de.fosd.typechef.typesystem._ import org.junit._ +import de.fosd.typechef.typesystem._ /** generated tests! do not modify! */ class GeneratedVarInitializerTests extends TestHelperTS { @@ -10,6 +10,9 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = 0; """) + correct(""" + void foo() { char x = 0; x = 0; } + """) } @@ -17,6 +20,9 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = 1; """) + correct(""" + void foo() { char x = 1; x = 1; } + """) } @@ -24,6 +30,9 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = -1; """) + correct(""" + void foo() { char x = -1; x = -1; } + """) } @@ -31,6 +40,9 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = 1l; """) + correct(""" + void foo() { char x = 1l; x = 1l; } + """) } @@ -38,6 +50,9 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = 0xa4; """) + correct(""" + void foo() { char x = 0xa4; x = 0xa4; } + """) } @@ -45,13 +60,16 @@ class GeneratedVarInitializerTests extends TestHelperTS { correct(""" char x = 0.2; """) + correct(""" + void foo() { char x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf0_6() { /* gcc reports: -test.c:1:24: warning: initialization makes integer from pointer without a cast +test.c:1:24: warning: initialization makes integer from pointer without a cast [enabled by default] char x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -62,13 +80,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" char x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { char x = "0.2"; x = "0.2"; } + ^ +test.c:1:46: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { char x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { char x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf0_7() { /* gcc reports: -test.c:1:24: warning: initialization makes integer from pointer without a cast +test.c:1:24: warning: initialization makes integer from pointer without a cast [enabled by default] char x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -79,6 +110,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" char x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { char x = &"foo"; x = &"foo"; } + ^ +test.c:1:47: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { char x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { char x = &"foo"; x = &"foo"; } + """) } @@ -93,13 +137,16 @@ test.c:1:15: error: initializer element is not constant error(""" char x = *"foo"; """) + correct(""" + void foo() { char x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf0_9() { /* gcc reports: -test.c:1:24: error: lvalue required as unary '&' operand +test.c:1:24: error: lvalue required as unary ‘&’ operand char x = &1; ^ @@ -107,6 +154,19 @@ test.c:1:24: error: lvalue required as unary '&' operand error(""" char x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: error: lvalue required as unary ‘&’ operand + void foo() { char x = &1; x = &1; } + ^ +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { char x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { char x = &1; x = &1; } + """) } @@ -114,6 +174,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = 0; """) + correct(""" + void foo() { signed char x = 0; x = 0; } + """) } @@ -121,6 +184,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = 1; """) + correct(""" + void foo() { signed char x = 1; x = 1; } + """) } @@ -128,6 +194,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = -1; """) + correct(""" + void foo() { signed char x = -1; x = -1; } + """) } @@ -135,6 +204,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = 1l; """) + correct(""" + void foo() { signed char x = 1l; x = 1l; } + """) } @@ -142,6 +214,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = 0xa4; """) + correct(""" + void foo() { signed char x = 0xa4; x = 0xa4; } + """) } @@ -149,13 +224,16 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" signed char x = 0.2; """) + correct(""" + void foo() { signed char x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf1_6() { /* gcc reports: -test.c:1:31: warning: initialization makes integer from pointer without a cast +test.c:1:31: warning: initialization makes integer from pointer without a cast [enabled by default] signed char x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -166,13 +244,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" signed char x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { signed char x = "0.2"; x = "0.2"; } + ^ +test.c:1:53: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { signed char x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { signed char x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf1_7() { /* gcc reports: -test.c:1:31: warning: initialization makes integer from pointer without a cast +test.c:1:31: warning: initialization makes integer from pointer without a cast [enabled by default] signed char x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -183,6 +274,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" signed char x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { signed char x = &"foo"; x = &"foo"; } + ^ +test.c:1:54: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { signed char x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { signed char x = &"foo"; x = &"foo"; } + """) } @@ -197,13 +301,16 @@ test.c:1:15: error: initializer element is not constant error(""" signed char x = *"foo"; """) + correct(""" + void foo() { signed char x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf1_9() { /* gcc reports: -test.c:1:31: error: lvalue required as unary '&' operand +test.c:1:31: error: lvalue required as unary ‘&’ operand signed char x = &1; ^ @@ -211,6 +318,19 @@ test.c:1:31: error: lvalue required as unary '&' operand error(""" signed char x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: error: lvalue required as unary ‘&’ operand + void foo() { signed char x = &1; x = &1; } + ^ +test.c:1:52: error: lvalue required as unary ‘&’ operand + void foo() { signed char x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { signed char x = &1; x = &1; } + """) } @@ -218,6 +338,9 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = 0; """) + correct(""" + void foo() { unsigned char x = 0; x = 0; } + """) } @@ -225,6 +348,9 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = 1; """) + correct(""" + void foo() { unsigned char x = 1; x = 1; } + """) } @@ -232,6 +358,9 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = -1; """) + correct(""" + void foo() { unsigned char x = -1; x = -1; } + """) } @@ -239,6 +368,9 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = 1l; """) + correct(""" + void foo() { unsigned char x = 1l; x = 1l; } + """) } @@ -246,6 +378,9 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = 0xa4; """) + correct(""" + void foo() { unsigned char x = 0xa4; x = 0xa4; } + """) } @@ -253,13 +388,16 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" unsigned char x = 0.2; """) + correct(""" + void foo() { unsigned char x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf2_6() { /* gcc reports: -test.c:1:33: warning: initialization makes integer from pointer without a cast +test.c:1:33: warning: initialization makes integer from pointer without a cast [enabled by default] unsigned char x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -270,13 +408,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" unsigned char x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { unsigned char x = "0.2"; x = "0.2"; } + ^ +test.c:1:55: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { unsigned char x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { unsigned char x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf2_7() { /* gcc reports: -test.c:1:33: warning: initialization makes integer from pointer without a cast +test.c:1:33: warning: initialization makes integer from pointer without a cast [enabled by default] unsigned char x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -287,6 +438,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" unsigned char x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { unsigned char x = &"foo"; x = &"foo"; } + ^ +test.c:1:56: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { unsigned char x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned char x = &"foo"; x = &"foo"; } + """) } @@ -301,13 +465,16 @@ test.c:1:15: error: initializer element is not constant error(""" unsigned char x = *"foo"; """) + correct(""" + void foo() { unsigned char x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf2_9() { /* gcc reports: -test.c:1:33: error: lvalue required as unary '&' operand +test.c:1:33: error: lvalue required as unary ‘&’ operand unsigned char x = &1; ^ @@ -315,6 +482,19 @@ test.c:1:33: error: lvalue required as unary '&' operand error(""" unsigned char x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char x = &1; x = &1; } + ^ +test.c:1:54: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { unsigned char x = &1; x = &1; } + """) } @@ -322,6 +502,9 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = 0; """) + correct(""" + void foo() { unsigned int x = 0; x = 0; } + """) } @@ -329,6 +512,9 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = 1; """) + correct(""" + void foo() { unsigned int x = 1; x = 1; } + """) } @@ -336,6 +522,9 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = -1; """) + correct(""" + void foo() { unsigned int x = -1; x = -1; } + """) } @@ -343,6 +532,9 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = 1l; """) + correct(""" + void foo() { unsigned int x = 1l; x = 1l; } + """) } @@ -350,6 +542,9 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = 0xa4; """) + correct(""" + void foo() { unsigned int x = 0xa4; x = 0xa4; } + """) } @@ -357,13 +552,16 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned int x = 0.2; """) + correct(""" + void foo() { unsigned int x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf3_6() { /* gcc reports: -test.c:1:32: warning: initialization makes integer from pointer without a cast +test.c:1:32: warning: initialization makes integer from pointer without a cast [enabled by default] unsigned int x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -374,13 +572,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" unsigned int x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { unsigned int x = "0.2"; x = "0.2"; } + ^ +test.c:1:54: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { unsigned int x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { unsigned int x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf3_7() { /* gcc reports: -test.c:1:32: warning: initialization makes integer from pointer without a cast +test.c:1:32: warning: initialization makes integer from pointer without a cast [enabled by default] unsigned int x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -391,6 +602,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" unsigned int x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { unsigned int x = &"foo"; x = &"foo"; } + ^ +test.c:1:55: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { unsigned int x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned int x = &"foo"; x = &"foo"; } + """) } @@ -405,13 +629,16 @@ test.c:1:15: error: initializer element is not constant error(""" unsigned int x = *"foo"; """) + correct(""" + void foo() { unsigned int x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf3_9() { /* gcc reports: -test.c:1:32: error: lvalue required as unary '&' operand +test.c:1:32: error: lvalue required as unary ‘&’ operand unsigned int x = &1; ^ @@ -419,6 +646,19 @@ test.c:1:32: error: lvalue required as unary '&' operand error(""" unsigned int x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { unsigned int x = &1; x = &1; } + ^ +test.c:1:53: error: lvalue required as unary ‘&’ operand + void foo() { unsigned int x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { unsigned int x = &1; x = &1; } + """) } @@ -426,6 +666,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = 0; """) + correct(""" + void foo() { signed int x = 0; x = 0; } + """) } @@ -433,6 +676,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = 1; """) + correct(""" + void foo() { signed int x = 1; x = 1; } + """) } @@ -440,6 +686,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = -1; """) + correct(""" + void foo() { signed int x = -1; x = -1; } + """) } @@ -447,6 +696,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = 1l; """) + correct(""" + void foo() { signed int x = 1l; x = 1l; } + """) } @@ -454,6 +706,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = 0xa4; """) + correct(""" + void foo() { signed int x = 0xa4; x = 0xa4; } + """) } @@ -461,13 +716,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" signed int x = 0.2; """) + correct(""" + void foo() { signed int x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf4_6() { /* gcc reports: -test.c:1:30: warning: initialization makes integer from pointer without a cast +test.c:1:30: warning: initialization makes integer from pointer without a cast [enabled by default] signed int x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -478,13 +736,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" signed int x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:43: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { signed int x = "0.2"; x = "0.2"; } + ^ +test.c:1:52: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { signed int x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { signed int x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf4_7() { /* gcc reports: -test.c:1:30: warning: initialization makes integer from pointer without a cast +test.c:1:30: warning: initialization makes integer from pointer without a cast [enabled by default] signed int x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -495,6 +766,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" signed int x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:43: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { signed int x = &"foo"; x = &"foo"; } + ^ +test.c:1:53: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { signed int x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { signed int x = &"foo"; x = &"foo"; } + """) } @@ -509,13 +793,16 @@ test.c:1:15: error: initializer element is not constant error(""" signed int x = *"foo"; """) + correct(""" + void foo() { signed int x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf4_9() { /* gcc reports: -test.c:1:30: error: lvalue required as unary '&' operand +test.c:1:30: error: lvalue required as unary ‘&’ operand signed int x = &1; ^ @@ -523,6 +810,19 @@ test.c:1:30: error: lvalue required as unary '&' operand error(""" signed int x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:43: error: lvalue required as unary ‘&’ operand + void foo() { signed int x = &1; x = &1; } + ^ +test.c:1:51: error: lvalue required as unary ‘&’ operand + void foo() { signed int x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { signed int x = &1; x = &1; } + """) } @@ -530,6 +830,9 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = 0; """) + correct(""" + void foo() { long x = 0; x = 0; } + """) } @@ -537,6 +840,9 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = 1; """) + correct(""" + void foo() { long x = 1; x = 1; } + """) } @@ -544,6 +850,9 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = -1; """) + correct(""" + void foo() { long x = -1; x = -1; } + """) } @@ -551,6 +860,9 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = 1l; """) + correct(""" + void foo() { long x = 1l; x = 1l; } + """) } @@ -558,6 +870,9 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = 0xa4; """) + correct(""" + void foo() { long x = 0xa4; x = 0xa4; } + """) } @@ -565,40 +880,63 @@ test.c:1:30: error: lvalue required as unary '&' operand correct(""" long x = 0.2; """) + correct(""" + void foo() { long x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf5_6() { /* gcc reports: -test.c:1:24: warning: initialization makes integer from pointer without a cast +test.c:1:24: warning: initialization makes integer from pointer without a cast [enabled by default] long x = "0.2"; ^ -test.c:1:15: error: initializer element is not computable at load time - long x = "0.2"; - ^ */ - error(""" + warning(""" long x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { long x = "0.2"; x = "0.2"; } + ^ +test.c:1:46: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { long x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { long x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf5_7() { /* gcc reports: -test.c:1:24: warning: initialization makes integer from pointer without a cast +test.c:1:24: warning: initialization makes integer from pointer without a cast [enabled by default] long x = &"foo"; ^ -test.c:1:15: error: initializer element is not computable at load time - long x = &"foo"; - ^ */ - error(""" + warning(""" long x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { long x = &"foo"; x = &"foo"; } + ^ +test.c:1:47: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { long x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { long x = &"foo"; x = &"foo"; } + """) } @@ -613,13 +951,16 @@ test.c:1:15: error: initializer element is not constant error(""" long x = *"foo"; """) + correct(""" + void foo() { long x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf5_9() { /* gcc reports: -test.c:1:24: error: lvalue required as unary '&' operand +test.c:1:24: error: lvalue required as unary ‘&’ operand long x = &1; ^ @@ -627,6 +968,19 @@ test.c:1:24: error: lvalue required as unary '&' operand error(""" long x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:37: error: lvalue required as unary ‘&’ operand + void foo() { long x = &1; x = &1; } + ^ +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { long x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { long x = &1; x = &1; } + """) } @@ -634,6 +988,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = 0; """) + correct(""" + void foo() { double x = 0; x = 0; } + """) } @@ -641,6 +998,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = 1; """) + correct(""" + void foo() { double x = 1; x = 1; } + """) } @@ -648,6 +1008,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = -1; """) + correct(""" + void foo() { double x = -1; x = -1; } + """) } @@ -655,6 +1018,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = 1l; """) + correct(""" + void foo() { double x = 1l; x = 1l; } + """) } @@ -662,6 +1028,9 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = 0xa4; """) + correct(""" + void foo() { double x = 0xa4; x = 0xa4; } + """) } @@ -669,13 +1038,16 @@ test.c:1:24: error: lvalue required as unary '&' operand correct(""" double x = 0.2; """) + correct(""" + void foo() { double x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf6_6() { /* gcc reports: -test.c:1:26: error: incompatible types when initializing type 'double' using type 'char *' +test.c:1:26: error: incompatible types when initializing type ‘double’ using type ‘char *’ double x = "0.2"; ^ @@ -683,13 +1055,26 @@ test.c:1:26: error: incompatible types when initializing type 'double' using typ error(""" double x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: error: incompatible types when initializing type ‘double’ using type ‘char *’ + void foo() { double x = "0.2"; x = "0.2"; } + ^ +test.c:1:48: error: incompatible types when assigning to type ‘double’ from type ‘char *’ + void foo() { double x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { double x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf6_7() { /* gcc reports: -test.c:1:26: error: incompatible types when initializing type 'double' using type 'char (*)[4]' +test.c:1:26: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ double x = &"foo"; ^ @@ -697,6 +1082,19 @@ test.c:1:26: error: incompatible types when initializing type 'double' using typ error(""" double x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ + void foo() { double x = &"foo"; x = &"foo"; } + ^ +test.c:1:49: error: incompatible types when assigning to type ‘double’ from type ‘char (*)[4]’ + void foo() { double x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { double x = &"foo"; x = &"foo"; } + """) } @@ -711,13 +1109,16 @@ test.c:1:15: error: initializer element is not constant error(""" double x = *"foo"; """) + correct(""" + void foo() { double x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf6_9() { /* gcc reports: -test.c:1:26: error: lvalue required as unary '&' operand +test.c:1:26: error: lvalue required as unary ‘&’ operand double x = &1; ^ @@ -725,6 +1126,19 @@ test.c:1:26: error: lvalue required as unary '&' operand error(""" double x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: error: lvalue required as unary ‘&’ operand + void foo() { double x = &1; x = &1; } + ^ +test.c:1:47: error: lvalue required as unary ‘&’ operand + void foo() { double x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { double x = &1; x = &1; } + """) } @@ -732,12 +1146,15 @@ test.c:1:26: error: lvalue required as unary '&' operand correct(""" int * x = 0; """) + correct(""" + void foo() { int * x = 0; x = 0; } + """) } @Test def test_conf7_1() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 1; ^ @@ -745,12 +1162,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1; x = 1; } + ^ +test.c:1:43: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { int * x = 1; x = 1; } + """) } @Test def test_conf7_2() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = -1; ^ @@ -758,12 +1188,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = -1; x = -1; } + ^ +test.c:1:44: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { int * x = -1; x = -1; } + """) } @Test def test_conf7_3() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 1l; ^ @@ -771,12 +1214,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1l; x = 1l; } + ^ +test.c:1:44: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { int * x = 1l; x = 1l; } + """) } @Test def test_conf7_4() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 0xa4; ^ @@ -784,12 +1240,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 0xa4; x = 0xa4; } + ^ +test.c:1:46: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { int * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf7_5() { /* gcc reports: -test.c:1:25: error: incompatible types when initializing type 'int *' using type 'double' +test.c:1:25: error: incompatible types when initializing type ‘int *’ using type ‘double’ int * x = 0.2; ^ @@ -797,13 +1266,26 @@ test.c:1:25: error: incompatible types when initializing type 'int *' using type error(""" int * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: error: incompatible types when initializing type ‘int *’ using type ‘double’ + void foo() { int * x = 0.2; x = 0.2; } + ^ +test.c:1:45: error: incompatible types when assigning to type ‘int *’ from type ‘double’ + void foo() { int * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { int * x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf7_6() { /* gcc reports: -test.c:1:25: warning: initialization from incompatible pointer type +test.c:1:25: warning: initialization from incompatible pointer type [enabled by default] int * x = "0.2"; ^ @@ -811,13 +1293,26 @@ test.c:1:25: warning: initialization from incompatible pointer type warning(""" int * x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization from incompatible pointer type [enabled by default] + void foo() { int * x = "0.2"; x = "0.2"; } + ^ +test.c:1:47: warning: assignment from incompatible pointer type [enabled by default] + void foo() { int * x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { int * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf7_7() { /* gcc reports: -test.c:1:25: warning: initialization from incompatible pointer type +test.c:1:25: warning: initialization from incompatible pointer type [enabled by default] int * x = &"foo"; ^ @@ -825,13 +1320,26 @@ test.c:1:25: warning: initialization from incompatible pointer type warning(""" int * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization from incompatible pointer type [enabled by default] + void foo() { int * x = &"foo"; x = &"foo"; } + ^ +test.c:1:48: warning: assignment from incompatible pointer type [enabled by default] + void foo() { int * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { int * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf7_8() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -842,13 +1350,26 @@ test.c:1:15: error: initializer element is not constant error(""" int * x = *"foo"; """) - } + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = *"foo"; x = *"foo"; } + ^ +test.c:1:48: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { int * x = *"foo"; x = *"foo"; } + """) + } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf7_9() { /* gcc reports: -test.c:1:25: error: lvalue required as unary '&' operand +test.c:1:25: error: lvalue required as unary ‘&’ operand int * x = &1; ^ @@ -856,6 +1377,19 @@ test.c:1:25: error: lvalue required as unary '&' operand error(""" int * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: error: lvalue required as unary ‘&’ operand + void foo() { int * x = &1; x = &1; } + ^ +test.c:1:46: error: lvalue required as unary ‘&’ operand + void foo() { int * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { int * x = &1; x = &1; } + """) } @@ -863,12 +1397,15 @@ test.c:1:25: error: lvalue required as unary '&' operand correct(""" char * x = 0; """) + correct(""" + void foo() { char * x = 0; x = 0; } + """) } @Test def test_conf8_1() { /* gcc reports: -test.c:1:26: warning: initialization makes pointer from integer without a cast +test.c:1:26: warning: initialization makes pointer from integer without a cast [enabled by default] char * x = 1; ^ @@ -876,12 +1413,25 @@ test.c:1:26: warning: initialization makes pointer from integer without a cast warning(""" char * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 1; x = 1; } + ^ +test.c:1:44: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { char * x = 1; x = 1; } + """) } @Test def test_conf8_2() { /* gcc reports: -test.c:1:26: warning: initialization makes pointer from integer without a cast +test.c:1:26: warning: initialization makes pointer from integer without a cast [enabled by default] char * x = -1; ^ @@ -889,12 +1439,25 @@ test.c:1:26: warning: initialization makes pointer from integer without a cast warning(""" char * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char * x = -1; x = -1; } + ^ +test.c:1:45: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { char * x = -1; x = -1; } + """) } @Test def test_conf8_3() { /* gcc reports: -test.c:1:26: warning: initialization makes pointer from integer without a cast +test.c:1:26: warning: initialization makes pointer from integer without a cast [enabled by default] char * x = 1l; ^ @@ -902,12 +1465,25 @@ test.c:1:26: warning: initialization makes pointer from integer without a cast warning(""" char * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 1l; x = 1l; } + ^ +test.c:1:45: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { char * x = 1l; x = 1l; } + """) } @Test def test_conf8_4() { /* gcc reports: -test.c:1:26: warning: initialization makes pointer from integer without a cast +test.c:1:26: warning: initialization makes pointer from integer without a cast [enabled by default] char * x = 0xa4; ^ @@ -915,12 +1491,25 @@ test.c:1:26: warning: initialization makes pointer from integer without a cast warning(""" char * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 0xa4; x = 0xa4; } + ^ +test.c:1:47: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { char * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf8_5() { /* gcc reports: -test.c:1:26: error: incompatible types when initializing type 'char *' using type 'double' +test.c:1:26: error: incompatible types when initializing type ‘char *’ using type ‘double’ char * x = 0.2; ^ @@ -928,6 +1517,19 @@ test.c:1:26: error: incompatible types when initializing type 'char *' using typ error(""" char * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: error: incompatible types when initializing type ‘char *’ using type ‘double’ + void foo() { char * x = 0.2; x = 0.2; } + ^ +test.c:1:46: error: incompatible types when assigning to type ‘char *’ from type ‘double’ + void foo() { char * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { char * x = 0.2; x = 0.2; } + """) } @@ -936,13 +1538,16 @@ test.c:1:26: error: incompatible types when initializing type 'char *' using typ correct(""" char * x = "0.2"; """) + correct(""" + void foo() { char * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf8_7() { /* gcc reports: -test.c:1:26: warning: initialization from incompatible pointer type +test.c:1:26: warning: initialization from incompatible pointer type [enabled by default] char * x = &"foo"; ^ @@ -950,13 +1555,26 @@ test.c:1:26: warning: initialization from incompatible pointer type warning(""" char * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization from incompatible pointer type [enabled by default] + void foo() { char * x = &"foo"; x = &"foo"; } + ^ +test.c:1:49: warning: assignment from incompatible pointer type [enabled by default] + void foo() { char * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { char * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf8_8() { /* gcc reports: -test.c:1:26: warning: initialization makes pointer from integer without a cast +test.c:1:26: warning: initialization makes pointer from integer without a cast [enabled by default] char * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -967,13 +1585,26 @@ test.c:1:15: error: initializer element is not constant error(""" char * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char * x = *"foo"; x = *"foo"; } + ^ +test.c:1:49: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { char * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf8_9() { /* gcc reports: -test.c:1:26: error: lvalue required as unary '&' operand +test.c:1:26: error: lvalue required as unary ‘&’ operand char * x = &1; ^ @@ -981,6 +1612,19 @@ test.c:1:26: error: lvalue required as unary '&' operand error(""" char * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:39: error: lvalue required as unary ‘&’ operand + void foo() { char * x = &1; x = &1; } + ^ +test.c:1:47: error: lvalue required as unary ‘&’ operand + void foo() { char * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { char * x = &1; x = &1; } + """) } @@ -988,12 +1632,15 @@ test.c:1:26: error: lvalue required as unary '&' operand correct(""" signed char * x = 0; """) + correct(""" + void foo() { signed char * x = 0; x = 0; } + """) } @Test def test_conf9_1() { /* gcc reports: -test.c:1:33: warning: initialization makes pointer from integer without a cast +test.c:1:33: warning: initialization makes pointer from integer without a cast [enabled by default] signed char * x = 1; ^ @@ -1001,12 +1648,25 @@ test.c:1:33: warning: initialization makes pointer from integer without a cast warning(""" signed char * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 1; x = 1; } + ^ +test.c:1:51: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { signed char * x = 1; x = 1; } + """) } @Test def test_conf9_2() { /* gcc reports: -test.c:1:33: warning: initialization makes pointer from integer without a cast +test.c:1:33: warning: initialization makes pointer from integer without a cast [enabled by default] signed char * x = -1; ^ @@ -1014,12 +1674,25 @@ test.c:1:33: warning: initialization makes pointer from integer without a cast warning(""" signed char * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = -1; x = -1; } + ^ +test.c:1:52: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { signed char * x = -1; x = -1; } + """) } @Test def test_conf9_3() { /* gcc reports: -test.c:1:33: warning: initialization makes pointer from integer without a cast +test.c:1:33: warning: initialization makes pointer from integer without a cast [enabled by default] signed char * x = 1l; ^ @@ -1027,12 +1700,25 @@ test.c:1:33: warning: initialization makes pointer from integer without a cast warning(""" signed char * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 1l; x = 1l; } + ^ +test.c:1:52: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { signed char * x = 1l; x = 1l; } + """) } @Test def test_conf9_4() { /* gcc reports: -test.c:1:33: warning: initialization makes pointer from integer without a cast +test.c:1:33: warning: initialization makes pointer from integer without a cast [enabled by default] signed char * x = 0xa4; ^ @@ -1040,12 +1726,25 @@ test.c:1:33: warning: initialization makes pointer from integer without a cast warning(""" signed char * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 0xa4; x = 0xa4; } + ^ +test.c:1:54: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { signed char * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf9_5() { /* gcc reports: -test.c:1:33: error: incompatible types when initializing type 'signed char *' using type 'double' +test.c:1:33: error: incompatible types when initializing type ‘signed char *’ using type ‘double’ signed char * x = 0.2; ^ @@ -1053,6 +1752,19 @@ test.c:1:33: error: incompatible types when initializing type 'signed char *' us error(""" signed char * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: error: incompatible types when initializing type ‘signed char *’ using type ‘double’ + void foo() { signed char * x = 0.2; x = 0.2; } + ^ +test.c:1:53: error: incompatible types when assigning to type ‘signed char *’ from type ‘double’ + void foo() { signed char * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { signed char * x = 0.2; x = 0.2; } + """) } @@ -1061,13 +1773,16 @@ test.c:1:33: error: incompatible types when initializing type 'signed char *' us correct(""" signed char * x = "0.2"; """) + correct(""" + void foo() { signed char * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf9_7() { /* gcc reports: -test.c:1:33: warning: initialization from incompatible pointer type +test.c:1:33: warning: initialization from incompatible pointer type [enabled by default] signed char * x = &"foo"; ^ @@ -1075,13 +1790,26 @@ test.c:1:33: warning: initialization from incompatible pointer type warning(""" signed char * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization from incompatible pointer type [enabled by default] + void foo() { signed char * x = &"foo"; x = &"foo"; } + ^ +test.c:1:56: warning: assignment from incompatible pointer type [enabled by default] + void foo() { signed char * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { signed char * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf9_8() { /* gcc reports: -test.c:1:33: warning: initialization makes pointer from integer without a cast +test.c:1:33: warning: initialization makes pointer from integer without a cast [enabled by default] signed char * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1092,13 +1820,26 @@ test.c:1:15: error: initializer element is not constant error(""" signed char * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = *"foo"; x = *"foo"; } + ^ +test.c:1:56: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { signed char * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf9_9() { /* gcc reports: -test.c:1:33: error: lvalue required as unary '&' operand +test.c:1:33: error: lvalue required as unary ‘&’ operand signed char * x = &1; ^ @@ -1106,6 +1847,19 @@ test.c:1:33: error: lvalue required as unary '&' operand error(""" signed char * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:46: error: lvalue required as unary ‘&’ operand + void foo() { signed char * x = &1; x = &1; } + ^ +test.c:1:54: error: lvalue required as unary ‘&’ operand + void foo() { signed char * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { signed char * x = &1; x = &1; } + """) } @@ -1113,12 +1867,15 @@ test.c:1:33: error: lvalue required as unary '&' operand correct(""" unsigned char * x = 0; """) + correct(""" + void foo() { unsigned char * x = 0; x = 0; } + """) } @Test def test_conf10_1() { /* gcc reports: -test.c:1:35: warning: initialization makes pointer from integer without a cast +test.c:1:35: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char * x = 1; ^ @@ -1126,12 +1883,25 @@ test.c:1:35: warning: initialization makes pointer from integer without a cast warning(""" unsigned char * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 1; x = 1; } + ^ +test.c:1:53: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = 1; x = 1; } + """) } @Test def test_conf10_2() { /* gcc reports: -test.c:1:35: warning: initialization makes pointer from integer without a cast +test.c:1:35: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char * x = -1; ^ @@ -1139,12 +1909,25 @@ test.c:1:35: warning: initialization makes pointer from integer without a cast warning(""" unsigned char * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = -1; x = -1; } + ^ +test.c:1:54: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = -1; x = -1; } + """) } @Test def test_conf10_3() { /* gcc reports: -test.c:1:35: warning: initialization makes pointer from integer without a cast +test.c:1:35: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char * x = 1l; ^ @@ -1152,12 +1935,25 @@ test.c:1:35: warning: initialization makes pointer from integer without a cast warning(""" unsigned char * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 1l; x = 1l; } + ^ +test.c:1:54: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = 1l; x = 1l; } + """) } @Test def test_conf10_4() { /* gcc reports: -test.c:1:35: warning: initialization makes pointer from integer without a cast +test.c:1:35: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char * x = 0xa4; ^ @@ -1165,12 +1961,25 @@ test.c:1:35: warning: initialization makes pointer from integer without a cast warning(""" unsigned char * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 0xa4; x = 0xa4; } + ^ +test.c:1:56: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf10_5() { /* gcc reports: -test.c:1:35: error: incompatible types when initializing type 'unsigned char *' using type 'double' +test.c:1:35: error: incompatible types when initializing type ‘unsigned char *’ using type ‘double’ unsigned char * x = 0.2; ^ @@ -1178,6 +1987,19 @@ test.c:1:35: error: incompatible types when initializing type 'unsigned char *' error(""" unsigned char * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: error: incompatible types when initializing type ‘unsigned char *’ using type ‘double’ + void foo() { unsigned char * x = 0.2; x = 0.2; } + ^ +test.c:1:55: error: incompatible types when assigning to type ‘unsigned char *’ from type ‘double’ + void foo() { unsigned char * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { unsigned char * x = 0.2; x = 0.2; } + """) } @@ -1186,13 +2008,16 @@ test.c:1:35: error: incompatible types when initializing type 'unsigned char *' correct(""" unsigned char * x = "0.2"; """) + correct(""" + void foo() { unsigned char * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf10_7() { /* gcc reports: -test.c:1:35: warning: initialization from incompatible pointer type +test.c:1:35: warning: initialization from incompatible pointer type [enabled by default] unsigned char * x = &"foo"; ^ @@ -1200,13 +2025,26 @@ test.c:1:35: warning: initialization from incompatible pointer type warning(""" unsigned char * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization from incompatible pointer type [enabled by default] + void foo() { unsigned char * x = &"foo"; x = &"foo"; } + ^ +test.c:1:58: warning: assignment from incompatible pointer type [enabled by default] + void foo() { unsigned char * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf10_8() { /* gcc reports: -test.c:1:35: warning: initialization makes pointer from integer without a cast +test.c:1:35: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1217,13 +2055,26 @@ test.c:1:15: error: initializer element is not constant error(""" unsigned char * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = *"foo"; x = *"foo"; } + ^ +test.c:1:58: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned char * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf10_9() { /* gcc reports: -test.c:1:35: error: lvalue required as unary '&' operand +test.c:1:35: error: lvalue required as unary ‘&’ operand unsigned char * x = &1; ^ @@ -1231,6 +2082,19 @@ test.c:1:35: error: lvalue required as unary '&' operand error(""" unsigned char * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char * x = &1; x = &1; } + ^ +test.c:1:56: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { unsigned char * x = &1; x = &1; } + """) } @@ -1238,12 +2102,15 @@ test.c:1:35: error: lvalue required as unary '&' operand correct(""" char ** x = 0; """) + correct(""" + void foo() { char ** x = 0; x = 0; } + """) } @Test def test_conf11_1() { /* gcc reports: -test.c:1:27: warning: initialization makes pointer from integer without a cast +test.c:1:27: warning: initialization makes pointer from integer without a cast [enabled by default] char ** x = 1; ^ @@ -1251,12 +2118,25 @@ test.c:1:27: warning: initialization makes pointer from integer without a cast warning(""" char ** x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 1; x = 1; } + ^ +test.c:1:45: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { char ** x = 1; x = 1; } + """) } @Test def test_conf11_2() { /* gcc reports: -test.c:1:27: warning: initialization makes pointer from integer without a cast +test.c:1:27: warning: initialization makes pointer from integer without a cast [enabled by default] char ** x = -1; ^ @@ -1264,12 +2144,25 @@ test.c:1:27: warning: initialization makes pointer from integer without a cast warning(""" char ** x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = -1; x = -1; } + ^ +test.c:1:46: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { char ** x = -1; x = -1; } + """) } @Test def test_conf11_3() { /* gcc reports: -test.c:1:27: warning: initialization makes pointer from integer without a cast +test.c:1:27: warning: initialization makes pointer from integer without a cast [enabled by default] char ** x = 1l; ^ @@ -1277,12 +2170,25 @@ test.c:1:27: warning: initialization makes pointer from integer without a cast warning(""" char ** x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 1l; x = 1l; } + ^ +test.c:1:46: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { char ** x = 1l; x = 1l; } + """) } @Test def test_conf11_4() { /* gcc reports: -test.c:1:27: warning: initialization makes pointer from integer without a cast +test.c:1:27: warning: initialization makes pointer from integer without a cast [enabled by default] char ** x = 0xa4; ^ @@ -1290,12 +2196,25 @@ test.c:1:27: warning: initialization makes pointer from integer without a cast warning(""" char ** x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 0xa4; x = 0xa4; } + ^ +test.c:1:48: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { char ** x = 0xa4; x = 0xa4; } + """) } @Test def test_conf11_5() { /* gcc reports: -test.c:1:27: error: incompatible types when initializing type 'char **' using type 'double' +test.c:1:27: error: incompatible types when initializing type ‘char **’ using type ‘double’ char ** x = 0.2; ^ @@ -1303,13 +2222,26 @@ test.c:1:27: error: incompatible types when initializing type 'char **' using ty error(""" char ** x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: error: incompatible types when initializing type ‘char **’ using type ‘double’ + void foo() { char ** x = 0.2; x = 0.2; } + ^ +test.c:1:47: error: incompatible types when assigning to type ‘char **’ from type ‘double’ + void foo() { char ** x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { char ** x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf11_6() { /* gcc reports: -test.c:1:27: warning: initialization from incompatible pointer type +test.c:1:27: warning: initialization from incompatible pointer type [enabled by default] char ** x = "0.2"; ^ @@ -1317,13 +2249,26 @@ test.c:1:27: warning: initialization from incompatible pointer type warning(""" char ** x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization from incompatible pointer type [enabled by default] + void foo() { char ** x = "0.2"; x = "0.2"; } + ^ +test.c:1:49: warning: assignment from incompatible pointer type [enabled by default] + void foo() { char ** x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { char ** x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf11_7() { /* gcc reports: -test.c:1:27: warning: initialization from incompatible pointer type +test.c:1:27: warning: initialization from incompatible pointer type [enabled by default] char ** x = &"foo"; ^ @@ -1331,13 +2276,26 @@ test.c:1:27: warning: initialization from incompatible pointer type warning(""" char ** x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization from incompatible pointer type [enabled by default] + void foo() { char ** x = &"foo"; x = &"foo"; } + ^ +test.c:1:50: warning: assignment from incompatible pointer type [enabled by default] + void foo() { char ** x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { char ** x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf11_8() { /* gcc reports: -test.c:1:27: warning: initialization makes pointer from integer without a cast +test.c:1:27: warning: initialization makes pointer from integer without a cast [enabled by default] char ** x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1348,13 +2306,26 @@ test.c:1:15: error: initializer element is not constant error(""" char ** x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = *"foo"; x = *"foo"; } + ^ +test.c:1:50: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { char ** x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { char ** x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf11_9() { /* gcc reports: -test.c:1:27: error: lvalue required as unary '&' operand +test.c:1:27: error: lvalue required as unary ‘&’ operand char ** x = &1; ^ @@ -1362,6 +2333,19 @@ test.c:1:27: error: lvalue required as unary '&' operand error(""" char ** x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:40: error: lvalue required as unary ‘&’ operand + void foo() { char ** x = &1; x = &1; } + ^ +test.c:1:48: error: lvalue required as unary ‘&’ operand + void foo() { char ** x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { char ** x = &1; x = &1; } + """) } @@ -1369,12 +2353,15 @@ test.c:1:27: error: lvalue required as unary '&' operand correct(""" unsigned char ** x = 0; """) + correct(""" + void foo() { unsigned char ** x = 0; x = 0; } + """) } @Test def test_conf12_1() { /* gcc reports: -test.c:1:36: warning: initialization makes pointer from integer without a cast +test.c:1:36: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char ** x = 1; ^ @@ -1382,12 +2369,25 @@ test.c:1:36: warning: initialization makes pointer from integer without a cast warning(""" unsigned char ** x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 1; x = 1; } + ^ +test.c:1:54: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = 1; x = 1; } + """) } @Test def test_conf12_2() { /* gcc reports: -test.c:1:36: warning: initialization makes pointer from integer without a cast +test.c:1:36: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char ** x = -1; ^ @@ -1395,12 +2395,25 @@ test.c:1:36: warning: initialization makes pointer from integer without a cast warning(""" unsigned char ** x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = -1; x = -1; } + ^ +test.c:1:55: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = -1; x = -1; } + """) } @Test def test_conf12_3() { /* gcc reports: -test.c:1:36: warning: initialization makes pointer from integer without a cast +test.c:1:36: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char ** x = 1l; ^ @@ -1408,12 +2421,25 @@ test.c:1:36: warning: initialization makes pointer from integer without a cast warning(""" unsigned char ** x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 1l; x = 1l; } + ^ +test.c:1:55: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = 1l; x = 1l; } + """) } @Test def test_conf12_4() { /* gcc reports: -test.c:1:36: warning: initialization makes pointer from integer without a cast +test.c:1:36: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char ** x = 0xa4; ^ @@ -1421,12 +2447,25 @@ test.c:1:36: warning: initialization makes pointer from integer without a cast warning(""" unsigned char ** x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 0xa4; x = 0xa4; } + ^ +test.c:1:57: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = 0xa4; x = 0xa4; } + """) } @Test def test_conf12_5() { /* gcc reports: -test.c:1:36: error: incompatible types when initializing type 'unsigned char **' using type 'double' +test.c:1:36: error: incompatible types when initializing type ‘unsigned char **’ using type ‘double’ unsigned char ** x = 0.2; ^ @@ -1434,13 +2473,26 @@ test.c:1:36: error: incompatible types when initializing type 'unsigned char **' error(""" unsigned char ** x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: error: incompatible types when initializing type ‘unsigned char **’ using type ‘double’ + void foo() { unsigned char ** x = 0.2; x = 0.2; } + ^ +test.c:1:56: error: incompatible types when assigning to type ‘unsigned char **’ from type ‘double’ + void foo() { unsigned char ** x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { unsigned char ** x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf12_6() { /* gcc reports: -test.c:1:36: warning: initialization from incompatible pointer type +test.c:1:36: warning: initialization from incompatible pointer type [enabled by default] unsigned char ** x = "0.2"; ^ @@ -1448,13 +2500,26 @@ test.c:1:36: warning: initialization from incompatible pointer type warning(""" unsigned char ** x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization from incompatible pointer type [enabled by default] + void foo() { unsigned char ** x = "0.2"; x = "0.2"; } + ^ +test.c:1:58: warning: assignment from incompatible pointer type [enabled by default] + void foo() { unsigned char ** x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf12_7() { /* gcc reports: -test.c:1:36: warning: initialization from incompatible pointer type +test.c:1:36: warning: initialization from incompatible pointer type [enabled by default] unsigned char ** x = &"foo"; ^ @@ -1462,13 +2527,26 @@ test.c:1:36: warning: initialization from incompatible pointer type warning(""" unsigned char ** x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization from incompatible pointer type [enabled by default] + void foo() { unsigned char ** x = &"foo"; x = &"foo"; } + ^ +test.c:1:59: warning: assignment from incompatible pointer type [enabled by default] + void foo() { unsigned char ** x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf12_8() { /* gcc reports: -test.c:1:36: warning: initialization makes pointer from integer without a cast +test.c:1:36: warning: initialization makes pointer from integer without a cast [enabled by default] unsigned char ** x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1479,13 +2557,26 @@ test.c:1:15: error: initializer element is not constant error(""" unsigned char ** x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = *"foo"; x = *"foo"; } + ^ +test.c:1:59: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { unsigned char ** x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { unsigned char ** x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf12_9() { /* gcc reports: -test.c:1:36: error: lvalue required as unary '&' operand +test.c:1:36: error: lvalue required as unary ‘&’ operand unsigned char ** x = &1; ^ @@ -1493,6 +2584,19 @@ test.c:1:36: error: lvalue required as unary '&' operand error(""" unsigned char ** x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:49: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char ** x = &1; x = &1; } + ^ +test.c:1:57: error: lvalue required as unary ‘&’ operand + void foo() { unsigned char ** x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { unsigned char ** x = &1; x = &1; } + """) } @@ -1500,12 +2604,15 @@ test.c:1:36: error: lvalue required as unary '&' operand correct(""" signed char ** x = 0; """) + correct(""" + void foo() { signed char ** x = 0; x = 0; } + """) } @Test def test_conf13_1() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] signed char ** x = 1; ^ @@ -1513,12 +2620,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" signed char ** x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 1; x = 1; } + ^ +test.c:1:52: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { signed char ** x = 1; x = 1; } + """) } @Test def test_conf13_2() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] signed char ** x = -1; ^ @@ -1526,12 +2646,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" signed char ** x = -1; """) - } - - - @Test def test_conf13_3() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = -1; x = -1; } + ^ +test.c:1:53: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { signed char ** x = -1; x = -1; } + """) + } + + + @Test def test_conf13_3() { + /* gcc reports: +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] signed char ** x = 1l; ^ @@ -1539,12 +2672,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" signed char ** x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 1l; x = 1l; } + ^ +test.c:1:53: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { signed char ** x = 1l; x = 1l; } + """) } @Test def test_conf13_4() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] signed char ** x = 0xa4; ^ @@ -1552,12 +2698,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" signed char ** x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 0xa4; x = 0xa4; } + ^ +test.c:1:55: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { signed char ** x = 0xa4; x = 0xa4; } + """) } @Test def test_conf13_5() { /* gcc reports: -test.c:1:34: error: incompatible types when initializing type 'signed char **' using type 'double' +test.c:1:34: error: incompatible types when initializing type ‘signed char **’ using type ‘double’ signed char ** x = 0.2; ^ @@ -1565,13 +2724,26 @@ test.c:1:34: error: incompatible types when initializing type 'signed char **' u error(""" signed char ** x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: error: incompatible types when initializing type ‘signed char **’ using type ‘double’ + void foo() { signed char ** x = 0.2; x = 0.2; } + ^ +test.c:1:54: error: incompatible types when assigning to type ‘signed char **’ from type ‘double’ + void foo() { signed char ** x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { signed char ** x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf13_6() { /* gcc reports: -test.c:1:34: warning: initialization from incompatible pointer type +test.c:1:34: warning: initialization from incompatible pointer type [enabled by default] signed char ** x = "0.2"; ^ @@ -1579,13 +2751,26 @@ test.c:1:34: warning: initialization from incompatible pointer type warning(""" signed char ** x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization from incompatible pointer type [enabled by default] + void foo() { signed char ** x = "0.2"; x = "0.2"; } + ^ +test.c:1:56: warning: assignment from incompatible pointer type [enabled by default] + void foo() { signed char ** x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { signed char ** x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf13_7() { /* gcc reports: -test.c:1:34: warning: initialization from incompatible pointer type +test.c:1:34: warning: initialization from incompatible pointer type [enabled by default] signed char ** x = &"foo"; ^ @@ -1593,13 +2778,26 @@ test.c:1:34: warning: initialization from incompatible pointer type warning(""" signed char ** x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization from incompatible pointer type [enabled by default] + void foo() { signed char ** x = &"foo"; x = &"foo"; } + ^ +test.c:1:57: warning: assignment from incompatible pointer type [enabled by default] + void foo() { signed char ** x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { signed char ** x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf13_8() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] signed char ** x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1610,13 +2808,26 @@ test.c:1:15: error: initializer element is not constant error(""" signed char ** x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = *"foo"; x = *"foo"; } + ^ +test.c:1:57: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { signed char ** x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { signed char ** x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf13_9() { /* gcc reports: -test.c:1:34: error: lvalue required as unary '&' operand +test.c:1:34: error: lvalue required as unary ‘&’ operand signed char ** x = &1; ^ @@ -1624,6 +2835,19 @@ test.c:1:34: error: lvalue required as unary '&' operand error(""" signed char ** x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: error: lvalue required as unary ‘&’ operand + void foo() { signed char ** x = &1; x = &1; } + ^ +test.c:1:55: error: lvalue required as unary ‘&’ operand + void foo() { signed char ** x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { signed char ** x = &1; x = &1; } + """) } @@ -1631,12 +2855,15 @@ test.c:1:34: error: lvalue required as unary '&' operand correct(""" double * x = 0; """) + correct(""" + void foo() { double * x = 0; x = 0; } + """) } @Test def test_conf14_1() { /* gcc reports: -test.c:1:28: warning: initialization makes pointer from integer without a cast +test.c:1:28: warning: initialization makes pointer from integer without a cast [enabled by default] double * x = 1; ^ @@ -1644,12 +2871,25 @@ test.c:1:28: warning: initialization makes pointer from integer without a cast warning(""" double * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 1; x = 1; } + ^ +test.c:1:46: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { double * x = 1; x = 1; } + """) } @Test def test_conf14_2() { /* gcc reports: -test.c:1:28: warning: initialization makes pointer from integer without a cast +test.c:1:28: warning: initialization makes pointer from integer without a cast [enabled by default] double * x = -1; ^ @@ -1657,12 +2897,25 @@ test.c:1:28: warning: initialization makes pointer from integer without a cast warning(""" double * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { double * x = -1; x = -1; } + ^ +test.c:1:47: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { double * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { double * x = -1; x = -1; } + """) } @Test def test_conf14_3() { /* gcc reports: -test.c:1:28: warning: initialization makes pointer from integer without a cast +test.c:1:28: warning: initialization makes pointer from integer without a cast [enabled by default] double * x = 1l; ^ @@ -1670,12 +2923,25 @@ test.c:1:28: warning: initialization makes pointer from integer without a cast warning(""" double * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 1l; x = 1l; } + ^ +test.c:1:47: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { double * x = 1l; x = 1l; } + """) } @Test def test_conf14_4() { /* gcc reports: -test.c:1:28: warning: initialization makes pointer from integer without a cast +test.c:1:28: warning: initialization makes pointer from integer without a cast [enabled by default] double * x = 0xa4; ^ @@ -1683,12 +2949,25 @@ test.c:1:28: warning: initialization makes pointer from integer without a cast warning(""" double * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 0xa4; x = 0xa4; } + ^ +test.c:1:49: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { double * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { double * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf14_5() { /* gcc reports: -test.c:1:28: error: incompatible types when initializing type 'double *' using type 'double' +test.c:1:28: error: incompatible types when initializing type ‘double *’ using type ‘double’ double * x = 0.2; ^ @@ -1696,13 +2975,26 @@ test.c:1:28: error: incompatible types when initializing type 'double *' using t error(""" double * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: error: incompatible types when initializing type ‘double *’ using type ‘double’ + void foo() { double * x = 0.2; x = 0.2; } + ^ +test.c:1:48: error: incompatible types when assigning to type ‘double *’ from type ‘double’ + void foo() { double * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { double * x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf14_6() { /* gcc reports: -test.c:1:28: warning: initialization from incompatible pointer type +test.c:1:28: warning: initialization from incompatible pointer type [enabled by default] double * x = "0.2"; ^ @@ -1710,13 +3002,26 @@ test.c:1:28: warning: initialization from incompatible pointer type warning(""" double * x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization from incompatible pointer type [enabled by default] + void foo() { double * x = "0.2"; x = "0.2"; } + ^ +test.c:1:50: warning: assignment from incompatible pointer type [enabled by default] + void foo() { double * x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { double * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf14_7() { /* gcc reports: -test.c:1:28: warning: initialization from incompatible pointer type +test.c:1:28: warning: initialization from incompatible pointer type [enabled by default] double * x = &"foo"; ^ @@ -1724,13 +3029,26 @@ test.c:1:28: warning: initialization from incompatible pointer type warning(""" double * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization from incompatible pointer type [enabled by default] + void foo() { double * x = &"foo"; x = &"foo"; } + ^ +test.c:1:51: warning: assignment from incompatible pointer type [enabled by default] + void foo() { double * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { double * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf14_8() { /* gcc reports: -test.c:1:28: warning: initialization makes pointer from integer without a cast +test.c:1:28: warning: initialization makes pointer from integer without a cast [enabled by default] double * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -1741,13 +3059,26 @@ test.c:1:15: error: initializer element is not constant error(""" double * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { double * x = *"foo"; x = *"foo"; } + ^ +test.c:1:51: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { double * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { double * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf14_9() { /* gcc reports: -test.c:1:28: error: lvalue required as unary '&' operand +test.c:1:28: error: lvalue required as unary ‘&’ operand double * x = &1; ^ @@ -1755,6 +3086,19 @@ test.c:1:28: error: lvalue required as unary '&' operand error(""" double * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:41: error: lvalue required as unary ‘&’ operand + void foo() { double * x = &1; x = &1; } + ^ +test.c:1:49: error: lvalue required as unary ‘&’ operand + void foo() { double * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { double * x = &1; x = &1; } + """) } @@ -1770,6 +3114,21 @@ test.c:3:22: error: invalid initializer struct S x = 0; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = 0; x = 0; } + ^ +test.c:3:46: error: incompatible types when assigning to type ‘struct S’ from type ‘int’ + void foo() { struct S x = 0; x = 0; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = 0; x = 0; } + """) } @@ -1785,6 +3144,21 @@ test.c:3:22: error: invalid initializer struct S x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = 1; x = 1; } + ^ +test.c:3:46: error: incompatible types when assigning to type ‘struct S’ from type ‘int’ + void foo() { struct S x = 1; x = 1; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = 1; x = 1; } + """) } @@ -1800,6 +3174,21 @@ test.c:3:22: error: invalid initializer struct S x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = -1; x = -1; } + ^ +test.c:3:47: error: incompatible types when assigning to type ‘struct S’ from type ‘int’ + void foo() { struct S x = -1; x = -1; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = -1; x = -1; } + """) } @@ -1815,6 +3204,21 @@ test.c:3:22: error: invalid initializer struct S x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = 1l; x = 1l; } + ^ +test.c:3:47: error: incompatible types when assigning to type ‘struct S’ from type ‘long int’ + void foo() { struct S x = 1l; x = 1l; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = 1l; x = 1l; } + """) } @@ -1830,6 +3234,21 @@ test.c:3:22: error: invalid initializer struct S x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = 0xa4; x = 0xa4; } + ^ +test.c:3:49: error: incompatible types when assigning to type ‘struct S’ from type ‘int’ + void foo() { struct S x = 0xa4; x = 0xa4; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = 0xa4; x = 0xa4; } + """) } @@ -1845,6 +3264,21 @@ test.c:3:22: error: invalid initializer struct S x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = 0.2; x = 0.2; } + ^ +test.c:3:48: error: incompatible types when assigning to type ‘struct S’ from type ‘double’ + void foo() { struct S x = 0.2; x = 0.2; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = 0.2; x = 0.2; } + """) } @@ -1861,6 +3295,21 @@ test.c:3:22: error: invalid initializer struct S x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = "0.2"; x = "0.2"; } + ^ +test.c:3:50: error: incompatible types when assigning to type ‘struct S’ from type ‘char *’ + void foo() { struct S x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = "0.2"; x = "0.2"; } + """) } @@ -1877,6 +3326,21 @@ test.c:3:22: error: invalid initializer struct S x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = &"foo"; x = &"foo"; } + ^ +test.c:3:51: error: incompatible types when assigning to type ‘struct S’ from type ‘char (*)[4]’ + void foo() { struct S x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = &"foo"; x = &"foo"; } + """) } @@ -1893,13 +3357,28 @@ test.c:3:22: error: invalid initializer struct S x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:35: error: invalid initializer + void foo() { struct S x = *"foo"; x = *"foo"; } + ^ +test.c:3:51: error: incompatible types when assigning to type ‘struct S’ from type ‘char’ + void foo() { struct S x = *"foo"; x = *"foo"; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf15_9() { /* gcc reports: -test.c:3:28: error: lvalue required as unary '&' operand +test.c:3:28: error: lvalue required as unary ‘&’ operand struct S x = &1; ^ @@ -1909,6 +3388,21 @@ test.c:3:28: error: lvalue required as unary '&' operand struct S x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:3:41: error: lvalue required as unary ‘&’ operand + void foo() { struct S x = &1; x = &1; } + ^ +test.c:3:49: error: lvalue required as unary ‘&’ operand + void foo() { struct S x = &1; x = &1; } + ^ + + */ + error(""" + struct S { int x; int y; }; + + void foo() { struct S x = &1; x = &1; } + """) } @@ -1922,6 +3416,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = 0; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = 0; x = 0; } + ^ +test.c:1:57: error: incompatible types when assigning to type ‘struct ’ from type ‘int’ + void foo() { struct { float b; } x = 0; x = 0; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = 0; x = 0; } + """) } @@ -1935,6 +3442,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = 1; x = 1; } + ^ +test.c:1:57: error: incompatible types when assigning to type ‘struct ’ from type ‘int’ + void foo() { struct { float b; } x = 1; x = 1; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = 1; x = 1; } + """) } @@ -1948,6 +3468,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = -1; x = -1; } + ^ +test.c:1:58: error: incompatible types when assigning to type ‘struct ’ from type ‘int’ + void foo() { struct { float b; } x = -1; x = -1; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = -1; x = -1; } + """) } @@ -1961,6 +3494,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = 1l; x = 1l; } + ^ +test.c:1:58: error: incompatible types when assigning to type ‘struct ’ from type ‘long int’ + void foo() { struct { float b; } x = 1l; x = 1l; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = 1l; x = 1l; } + """) } @@ -1974,6 +3520,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = 0xa4; x = 0xa4; } + ^ +test.c:1:60: error: incompatible types when assigning to type ‘struct ’ from type ‘int’ + void foo() { struct { float b; } x = 0xa4; x = 0xa4; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = 0xa4; x = 0xa4; } + """) } @@ -1987,6 +3546,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = 0.2; x = 0.2; } + ^ +test.c:1:59: error: incompatible types when assigning to type ‘struct ’ from type ‘double’ + void foo() { struct { float b; } x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = 0.2; x = 0.2; } + """) } @@ -2001,6 +3573,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = "0.2"; x = "0.2"; } + ^ +test.c:1:61: error: incompatible types when assigning to type ‘struct ’ from type ‘char *’ + void foo() { struct { float b; } x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = "0.2"; x = "0.2"; } + """) } @@ -2015,6 +3600,19 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = &"foo"; x = &"foo"; } + ^ +test.c:1:62: error: incompatible types when assigning to type ‘struct ’ from type ‘char (*)[4]’ + void foo() { struct { float b; } x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = &"foo"; x = &"foo"; } + """) } @@ -2029,13 +3627,26 @@ test.c:1:22: error: invalid initializer error(""" struct { float b; } x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:35: error: invalid initializer + void foo() { struct { float b; } x = *"foo"; x = *"foo"; } + ^ +test.c:1:62: error: incompatible types when assigning to type ‘struct ’ from type ‘char’ + void foo() { struct { float b; } x = *"foo"; x = *"foo"; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf16_9() { /* gcc reports: -test.c:1:39: error: lvalue required as unary '&' operand +test.c:1:39: error: lvalue required as unary ‘&’ operand struct { float b; } x = &1; ^ @@ -2043,6 +3654,19 @@ test.c:1:39: error: lvalue required as unary '&' operand error(""" struct { float b; } x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:52: error: lvalue required as unary ‘&’ operand + void foo() { struct { float b; } x = &1; x = &1; } + ^ +test.c:1:60: error: lvalue required as unary ‘&’ operand + void foo() { struct { float b; } x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { struct { float b; } x = &1; x = &1; } + """) } @@ -2050,6 +3674,9 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = 0; """) + correct(""" + void foo() { volatile int x = 0; x = 0; } + """) } @@ -2057,6 +3684,9 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = 1; """) + correct(""" + void foo() { volatile int x = 1; x = 1; } + """) } @@ -2064,6 +3694,9 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = -1; """) + correct(""" + void foo() { volatile int x = -1; x = -1; } + """) } @@ -2071,6 +3704,9 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = 1l; """) + correct(""" + void foo() { volatile int x = 1l; x = 1l; } + """) } @@ -2078,6 +3714,9 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = 0xa4; """) + correct(""" + void foo() { volatile int x = 0xa4; x = 0xa4; } + """) } @@ -2085,13 +3724,16 @@ test.c:1:39: error: lvalue required as unary '&' operand correct(""" volatile int x = 0.2; """) + correct(""" + void foo() { volatile int x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf17_6() { /* gcc reports: -test.c:1:32: warning: initialization makes integer from pointer without a cast +test.c:1:32: warning: initialization makes integer from pointer without a cast [enabled by default] volatile int x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -2102,13 +3744,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" volatile int x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { volatile int x = "0.2"; x = "0.2"; } + ^ +test.c:1:54: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { volatile int x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { volatile int x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf17_7() { /* gcc reports: -test.c:1:32: warning: initialization makes integer from pointer without a cast +test.c:1:32: warning: initialization makes integer from pointer without a cast [enabled by default] volatile int x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -2119,6 +3774,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" volatile int x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { volatile int x = &"foo"; x = &"foo"; } + ^ +test.c:1:55: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { volatile int x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { volatile int x = &"foo"; x = &"foo"; } + """) } @@ -2133,13 +3801,16 @@ test.c:1:15: error: initializer element is not constant error(""" volatile int x = *"foo"; """) + correct(""" + void foo() { volatile int x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf17_9() { /* gcc reports: -test.c:1:32: error: lvalue required as unary '&' operand +test.c:1:32: error: lvalue required as unary ‘&’ operand volatile int x = &1; ^ @@ -2147,6 +3818,19 @@ test.c:1:32: error: lvalue required as unary '&' operand error(""" volatile int x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { volatile int x = &1; x = &1; } + ^ +test.c:1:53: error: lvalue required as unary ‘&’ operand + void foo() { volatile int x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { volatile int x = &1; x = &1; } + """) } @@ -2154,6 +3838,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = 0; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = 0; x = 0; } + ^ + + */ + error(""" + void foo() { const int x = 0; x = 0; } + """) } @@ -2161,6 +3855,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = 1; x = 1; } + ^ + + */ + error(""" + void foo() { const int x = 1; x = 1; } + """) } @@ -2168,6 +3872,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = -1; x = -1; } + ^ + + */ + error(""" + void foo() { const int x = -1; x = -1; } + """) } @@ -2175,6 +3889,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = 1l; x = 1l; } + ^ + + */ + error(""" + void foo() { const int x = 1l; x = 1l; } + """) } @@ -2182,6 +3906,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = 0xa4; x = 0xa4; } + ^ + + */ + error(""" + void foo() { const int x = 0xa4; x = 0xa4; } + """) } @@ -2189,13 +3923,23 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" const int x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { const int x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf18_6() { /* gcc reports: -test.c:1:29: warning: initialization makes integer from pointer without a cast +test.c:1:29: warning: initialization makes integer from pointer without a cast [enabled by default] const int x = "0.2"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -2206,13 +3950,26 @@ test.c:1:15: error: initializer element is not computable at load time error(""" const int x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:42: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { const int x = "0.2"; x = "0.2"; } + ^ +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { const int x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf18_7() { /* gcc reports: -test.c:1:29: warning: initialization makes integer from pointer without a cast +test.c:1:29: warning: initialization makes integer from pointer without a cast [enabled by default] const int x = &"foo"; ^ test.c:1:15: error: initializer element is not computable at load time @@ -2223,6 +3980,19 @@ test.c:1:15: error: initializer element is not computable at load time error(""" const int x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:42: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { const int x = &"foo"; x = &"foo"; } + ^ +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { const int x = &"foo"; x = &"foo"; } + """) } @@ -2237,13 +4007,23 @@ test.c:1:15: error: initializer element is not constant error(""" const int x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const int x = *"foo"; x = *"foo"; } + ^ + + */ + error(""" + void foo() { const int x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf18_9() { /* gcc reports: -test.c:1:29: error: lvalue required as unary '&' operand +test.c:1:29: error: lvalue required as unary ‘&’ operand const int x = &1; ^ @@ -2251,6 +4031,19 @@ test.c:1:29: error: lvalue required as unary '&' operand error(""" const int x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:42: error: lvalue required as unary ‘&’ operand + void foo() { const int x = &1; x = &1; } + ^ +test.c:1:50: error: lvalue required as unary ‘&’ operand + void foo() { const int x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { const int x = &1; x = &1; } + """) } @@ -2258,6 +4051,16 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = 0; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = 0; x = 0; } + ^ + + */ + error(""" + void foo() { const double x = 0; x = 0; } + """) } @@ -2265,6 +4068,16 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = 1; x = 1; } + ^ + + */ + error(""" + void foo() { const double x = 1; x = 1; } + """) } @@ -2272,6 +4085,16 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = -1; x = -1; } + ^ + + */ + error(""" + void foo() { const double x = -1; x = -1; } + """) } @@ -2279,6 +4102,16 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = 1l; x = 1l; } + ^ + + */ + error(""" + void foo() { const double x = 1l; x = 1l; } + """) } @@ -2286,6 +4119,16 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = 0xa4; x = 0xa4; } + ^ + + */ + error(""" + void foo() { const double x = 0xa4; x = 0xa4; } + """) } @@ -2293,13 +4136,23 @@ test.c:1:29: error: lvalue required as unary '&' operand correct(""" const double x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { const double x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf19_6() { /* gcc reports: -test.c:1:32: error: incompatible types when initializing type 'double' using type 'char *' +test.c:1:32: error: incompatible types when initializing type ‘double’ using type ‘char *’ const double x = "0.2"; ^ @@ -2307,13 +4160,26 @@ test.c:1:32: error: incompatible types when initializing type 'double' using typ error(""" const double x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: error: incompatible types when initializing type ‘double’ using type ‘char *’ + void foo() { const double x = "0.2"; x = "0.2"; } + ^ +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { const double x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf19_7() { /* gcc reports: -test.c:1:32: error: incompatible types when initializing type 'double' using type 'char (*)[4]' +test.c:1:32: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ const double x = &"foo"; ^ @@ -2321,6 +4187,19 @@ test.c:1:32: error: incompatible types when initializing type 'double' using typ error(""" const double x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ + void foo() { const double x = &"foo"; x = &"foo"; } + ^ +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { const double x = &"foo"; x = &"foo"; } + """) } @@ -2335,13 +4214,23 @@ test.c:1:15: error: initializer element is not constant error(""" const double x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:15: error: assignment of read-only variable ‘x’ + void foo() { const double x = *"foo"; x = *"foo"; } + ^ + + */ + error(""" + void foo() { const double x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf19_9() { /* gcc reports: -test.c:1:32: error: lvalue required as unary '&' operand +test.c:1:32: error: lvalue required as unary ‘&’ operand const double x = &1; ^ @@ -2349,6 +4238,19 @@ test.c:1:32: error: lvalue required as unary '&' operand error(""" const double x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { const double x = &1; x = &1; } + ^ +test.c:1:53: error: lvalue required as unary ‘&’ operand + void foo() { const double x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { const double x = &1; x = &1; } + """) } @@ -2356,6 +4258,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = 0; """) + correct(""" + void foo() { volatile double x = 0; x = 0; } + """) } @@ -2363,6 +4268,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = 1; """) + correct(""" + void foo() { volatile double x = 1; x = 1; } + """) } @@ -2370,6 +4278,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = -1; """) + correct(""" + void foo() { volatile double x = -1; x = -1; } + """) } @@ -2377,6 +4288,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = 1l; """) + correct(""" + void foo() { volatile double x = 1l; x = 1l; } + """) } @@ -2384,6 +4298,9 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = 0xa4; """) + correct(""" + void foo() { volatile double x = 0xa4; x = 0xa4; } + """) } @@ -2391,13 +4308,16 @@ test.c:1:32: error: lvalue required as unary '&' operand correct(""" volatile double x = 0.2; """) + correct(""" + void foo() { volatile double x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf20_6() { /* gcc reports: -test.c:1:35: error: incompatible types when initializing type 'double' using type 'char *' +test.c:1:35: error: incompatible types when initializing type ‘double’ using type ‘char *’ volatile double x = "0.2"; ^ @@ -2405,13 +4325,26 @@ test.c:1:35: error: incompatible types when initializing type 'double' using typ error(""" volatile double x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: error: incompatible types when initializing type ‘double’ using type ‘char *’ + void foo() { volatile double x = "0.2"; x = "0.2"; } + ^ +test.c:1:57: error: incompatible types when assigning to type ‘double’ from type ‘char *’ + void foo() { volatile double x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { volatile double x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf20_7() { /* gcc reports: -test.c:1:35: error: incompatible types when initializing type 'double' using type 'char (*)[4]' +test.c:1:35: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ volatile double x = &"foo"; ^ @@ -2419,6 +4352,19 @@ test.c:1:35: error: incompatible types when initializing type 'double' using typ error(""" volatile double x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: error: incompatible types when initializing type ‘double’ using type ‘char (*)[4]’ + void foo() { volatile double x = &"foo"; x = &"foo"; } + ^ +test.c:1:58: error: incompatible types when assigning to type ‘double’ from type ‘char (*)[4]’ + void foo() { volatile double x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { volatile double x = &"foo"; x = &"foo"; } + """) } @@ -2433,13 +4379,16 @@ test.c:1:15: error: initializer element is not constant error(""" volatile double x = *"foo"; """) + correct(""" + void foo() { volatile double x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf20_9() { /* gcc reports: -test.c:1:35: error: lvalue required as unary '&' operand +test.c:1:35: error: lvalue required as unary ‘&’ operand volatile double x = &1; ^ @@ -2447,6 +4396,19 @@ test.c:1:35: error: lvalue required as unary '&' operand error(""" volatile double x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:48: error: lvalue required as unary ‘&’ operand + void foo() { volatile double x = &1; x = &1; } + ^ +test.c:1:56: error: lvalue required as unary ‘&’ operand + void foo() { volatile double x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { volatile double x = &1; x = &1; } + """) } @@ -2454,12 +4416,15 @@ test.c:1:35: error: lvalue required as unary '&' operand correct(""" int * x = 0; """) + correct(""" + void foo() { int * x = 0; x = 0; } + """) } @Test def test_conf21_1() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 1; ^ @@ -2467,12 +4432,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1; x = 1; } + ^ +test.c:1:43: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { int * x = 1; x = 1; } + """) } @Test def test_conf21_2() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = -1; ^ @@ -2480,12 +4458,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = -1; x = -1; } + ^ +test.c:1:44: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { int * x = -1; x = -1; } + """) } @Test def test_conf21_3() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 1l; ^ @@ -2493,12 +4484,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1l; x = 1l; } + ^ +test.c:1:44: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { int * x = 1l; x = 1l; } + """) } @Test def test_conf21_4() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = 0xa4; ^ @@ -2506,12 +4510,25 @@ test.c:1:25: warning: initialization makes pointer from integer without a cast warning(""" int * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 0xa4; x = 0xa4; } + ^ +test.c:1:46: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { int * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf21_5() { /* gcc reports: -test.c:1:25: error: incompatible types when initializing type 'int *' using type 'double' +test.c:1:25: error: incompatible types when initializing type ‘int *’ using type ‘double’ int * x = 0.2; ^ @@ -2519,13 +4536,26 @@ test.c:1:25: error: incompatible types when initializing type 'int *' using type error(""" int * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: error: incompatible types when initializing type ‘int *’ using type ‘double’ + void foo() { int * x = 0.2; x = 0.2; } + ^ +test.c:1:45: error: incompatible types when assigning to type ‘int *’ from type ‘double’ + void foo() { int * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { int * x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf21_6() { /* gcc reports: -test.c:1:25: warning: initialization from incompatible pointer type +test.c:1:25: warning: initialization from incompatible pointer type [enabled by default] int * x = "0.2"; ^ @@ -2533,13 +4563,26 @@ test.c:1:25: warning: initialization from incompatible pointer type warning(""" int * x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization from incompatible pointer type [enabled by default] + void foo() { int * x = "0.2"; x = "0.2"; } + ^ +test.c:1:47: warning: assignment from incompatible pointer type [enabled by default] + void foo() { int * x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { int * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf21_7() { /* gcc reports: -test.c:1:25: warning: initialization from incompatible pointer type +test.c:1:25: warning: initialization from incompatible pointer type [enabled by default] int * x = &"foo"; ^ @@ -2547,13 +4590,26 @@ test.c:1:25: warning: initialization from incompatible pointer type warning(""" int * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization from incompatible pointer type [enabled by default] + void foo() { int * x = &"foo"; x = &"foo"; } + ^ +test.c:1:48: warning: assignment from incompatible pointer type [enabled by default] + void foo() { int * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { int * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf21_8() { /* gcc reports: -test.c:1:25: warning: initialization makes pointer from integer without a cast +test.c:1:25: warning: initialization makes pointer from integer without a cast [enabled by default] int * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -2564,13 +4620,26 @@ test.c:1:15: error: initializer element is not constant error(""" int * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { int * x = *"foo"; x = *"foo"; } + ^ +test.c:1:48: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { int * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { int * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf21_9() { /* gcc reports: -test.c:1:25: error: lvalue required as unary '&' operand +test.c:1:25: error: lvalue required as unary ‘&’ operand int * x = &1; ^ @@ -2578,6 +4647,19 @@ test.c:1:25: error: lvalue required as unary '&' operand error(""" int * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:38: error: lvalue required as unary ‘&’ operand + void foo() { int * x = &1; x = &1; } + ^ +test.c:1:46: error: lvalue required as unary ‘&’ operand + void foo() { int * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { int * x = &1; x = &1; } + """) } @@ -2585,12 +4667,15 @@ test.c:1:25: error: lvalue required as unary '&' operand correct(""" const int * x = 0; """) + correct(""" + void foo() { const int * x = 0; x = 0; } + """) } @Test def test_conf22_1() { /* gcc reports: -test.c:1:31: warning: initialization makes pointer from integer without a cast +test.c:1:31: warning: initialization makes pointer from integer without a cast [enabled by default] const int * x = 1; ^ @@ -2598,12 +4683,25 @@ test.c:1:31: warning: initialization makes pointer from integer without a cast warning(""" const int * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 1; x = 1; } + ^ +test.c:1:49: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { const int * x = 1; x = 1; } + """) } @Test def test_conf22_2() { /* gcc reports: -test.c:1:31: warning: initialization makes pointer from integer without a cast +test.c:1:31: warning: initialization makes pointer from integer without a cast [enabled by default] const int * x = -1; ^ @@ -2611,12 +4709,25 @@ test.c:1:31: warning: initialization makes pointer from integer without a cast warning(""" const int * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = -1; x = -1; } + ^ +test.c:1:50: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { const int * x = -1; x = -1; } + """) } @Test def test_conf22_3() { /* gcc reports: -test.c:1:31: warning: initialization makes pointer from integer without a cast +test.c:1:31: warning: initialization makes pointer from integer without a cast [enabled by default] const int * x = 1l; ^ @@ -2624,12 +4735,25 @@ test.c:1:31: warning: initialization makes pointer from integer without a cast warning(""" const int * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 1l; x = 1l; } + ^ +test.c:1:50: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { const int * x = 1l; x = 1l; } + """) } @Test def test_conf22_4() { /* gcc reports: -test.c:1:31: warning: initialization makes pointer from integer without a cast +test.c:1:31: warning: initialization makes pointer from integer without a cast [enabled by default] const int * x = 0xa4; ^ @@ -2637,12 +4761,25 @@ test.c:1:31: warning: initialization makes pointer from integer without a cast warning(""" const int * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 0xa4; x = 0xa4; } + ^ +test.c:1:52: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { const int * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf22_5() { /* gcc reports: -test.c:1:31: error: incompatible types when initializing type 'const int *' using type 'double' +test.c:1:31: error: incompatible types when initializing type ‘const int *’ using type ‘double’ const int * x = 0.2; ^ @@ -2650,13 +4787,26 @@ test.c:1:31: error: incompatible types when initializing type 'const int *' usin error(""" const int * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: error: incompatible types when initializing type ‘const int *’ using type ‘double’ + void foo() { const int * x = 0.2; x = 0.2; } + ^ +test.c:1:51: error: incompatible types when assigning to type ‘const int *’ from type ‘double’ + void foo() { const int * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { const int * x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf22_6() { /* gcc reports: -test.c:1:31: warning: initialization from incompatible pointer type +test.c:1:31: warning: initialization from incompatible pointer type [enabled by default] const int * x = "0.2"; ^ @@ -2664,13 +4814,26 @@ test.c:1:31: warning: initialization from incompatible pointer type warning(""" const int * x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization from incompatible pointer type [enabled by default] + void foo() { const int * x = "0.2"; x = "0.2"; } + ^ +test.c:1:53: warning: assignment from incompatible pointer type [enabled by default] + void foo() { const int * x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { const int * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf22_7() { /* gcc reports: -test.c:1:31: warning: initialization from incompatible pointer type +test.c:1:31: warning: initialization from incompatible pointer type [enabled by default] const int * x = &"foo"; ^ @@ -2678,13 +4841,26 @@ test.c:1:31: warning: initialization from incompatible pointer type warning(""" const int * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization from incompatible pointer type [enabled by default] + void foo() { const int * x = &"foo"; x = &"foo"; } + ^ +test.c:1:54: warning: assignment from incompatible pointer type [enabled by default] + void foo() { const int * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { const int * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf22_8() { /* gcc reports: -test.c:1:31: warning: initialization makes pointer from integer without a cast +test.c:1:31: warning: initialization makes pointer from integer without a cast [enabled by default] const int * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -2695,13 +4871,26 @@ test.c:1:15: error: initializer element is not constant error(""" const int * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = *"foo"; x = *"foo"; } + ^ +test.c:1:54: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { const int * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { const int * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf22_9() { /* gcc reports: -test.c:1:31: error: lvalue required as unary '&' operand +test.c:1:31: error: lvalue required as unary ‘&’ operand const int * x = &1; ^ @@ -2709,6 +4898,19 @@ test.c:1:31: error: lvalue required as unary '&' operand error(""" const int * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:44: error: lvalue required as unary ‘&’ operand + void foo() { const int * x = &1; x = &1; } + ^ +test.c:1:52: error: lvalue required as unary ‘&’ operand + void foo() { const int * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { const int * x = &1; x = &1; } + """) } @@ -2716,12 +4918,15 @@ test.c:1:31: error: lvalue required as unary '&' operand correct(""" volatile int * x = 0; """) + correct(""" + void foo() { volatile int * x = 0; x = 0; } + """) } @Test def test_conf23_1() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] volatile int * x = 1; ^ @@ -2729,12 +4934,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" volatile int * x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 1; x = 1; } + ^ +test.c:1:52: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 1; x = 1; } + ^ + + */ + warning(""" + void foo() { volatile int * x = 1; x = 1; } + """) } @Test def test_conf23_2() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] volatile int * x = -1; ^ @@ -2742,12 +4960,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" volatile int * x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = -1; x = -1; } + ^ +test.c:1:53: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = -1; x = -1; } + ^ + + */ + warning(""" + void foo() { volatile int * x = -1; x = -1; } + """) } @Test def test_conf23_3() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] volatile int * x = 1l; ^ @@ -2755,12 +4986,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" volatile int * x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 1l; x = 1l; } + ^ +test.c:1:53: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 1l; x = 1l; } + ^ + + */ + warning(""" + void foo() { volatile int * x = 1l; x = 1l; } + """) } @Test def test_conf23_4() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] volatile int * x = 0xa4; ^ @@ -2768,12 +5012,25 @@ test.c:1:34: warning: initialization makes pointer from integer without a cast warning(""" volatile int * x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 0xa4; x = 0xa4; } + ^ +test.c:1:55: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = 0xa4; x = 0xa4; } + ^ + + */ + warning(""" + void foo() { volatile int * x = 0xa4; x = 0xa4; } + """) } @Test def test_conf23_5() { /* gcc reports: -test.c:1:34: error: incompatible types when initializing type 'volatile int *' using type 'double' +test.c:1:34: error: incompatible types when initializing type ‘volatile int *’ using type ‘double’ volatile int * x = 0.2; ^ @@ -2781,13 +5038,26 @@ test.c:1:34: error: incompatible types when initializing type 'volatile int *' u error(""" volatile int * x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: error: incompatible types when initializing type ‘volatile int *’ using type ‘double’ + void foo() { volatile int * x = 0.2; x = 0.2; } + ^ +test.c:1:54: error: incompatible types when assigning to type ‘volatile int *’ from type ‘double’ + void foo() { volatile int * x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { volatile int * x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf23_6() { /* gcc reports: -test.c:1:34: warning: initialization from incompatible pointer type +test.c:1:34: warning: initialization from incompatible pointer type [enabled by default] volatile int * x = "0.2"; ^ @@ -2795,13 +5065,26 @@ test.c:1:34: warning: initialization from incompatible pointer type warning(""" volatile int * x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization from incompatible pointer type [enabled by default] + void foo() { volatile int * x = "0.2"; x = "0.2"; } + ^ +test.c:1:56: warning: assignment from incompatible pointer type [enabled by default] + void foo() { volatile int * x = "0.2"; x = "0.2"; } + ^ + + */ + warning(""" + void foo() { volatile int * x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf23_7() { /* gcc reports: -test.c:1:34: warning: initialization from incompatible pointer type +test.c:1:34: warning: initialization from incompatible pointer type [enabled by default] volatile int * x = &"foo"; ^ @@ -2809,13 +5092,26 @@ test.c:1:34: warning: initialization from incompatible pointer type warning(""" volatile int * x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization from incompatible pointer type [enabled by default] + void foo() { volatile int * x = &"foo"; x = &"foo"; } + ^ +test.c:1:57: warning: assignment from incompatible pointer type [enabled by default] + void foo() { volatile int * x = &"foo"; x = &"foo"; } + ^ + + */ + warning(""" + void foo() { volatile int * x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf23_8() { /* gcc reports: -test.c:1:34: warning: initialization makes pointer from integer without a cast +test.c:1:34: warning: initialization makes pointer from integer without a cast [enabled by default] volatile int * x = *"foo"; ^ test.c:1:15: error: initializer element is not constant @@ -2826,13 +5122,26 @@ test.c:1:15: error: initializer element is not constant error(""" volatile int * x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: warning: initialization makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = *"foo"; x = *"foo"; } + ^ +test.c:1:57: warning: assignment makes pointer from integer without a cast [enabled by default] + void foo() { volatile int * x = *"foo"; x = *"foo"; } + ^ + + */ + warning(""" + void foo() { volatile int * x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf23_9() { /* gcc reports: -test.c:1:34: error: lvalue required as unary '&' operand +test.c:1:34: error: lvalue required as unary ‘&’ operand volatile int * x = &1; ^ @@ -2840,12 +5149,25 @@ test.c:1:34: error: lvalue required as unary '&' operand error(""" volatile int * x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:47: error: lvalue required as unary ‘&’ operand + void foo() { volatile int * x = &1; x = &1; } + ^ +test.c:1:55: error: lvalue required as unary ‘&’ operand + void foo() { volatile int * x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { volatile int * x = &1; x = &1; } + """) } @Test def test_conf24_0() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = 0; ^ @@ -2853,12 +5175,22 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = 0; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = 0; x = 0; } + ^ + + */ + error(""" + void foo() { void x = 0; x = 0; } + """) } @Test def test_conf24_1() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = 1; ^ @@ -2866,12 +5198,22 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = 1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = 1; x = 1; } + ^ + + */ + error(""" + void foo() { void x = 1; x = 1; } + """) } @Test def test_conf24_2() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = -1; ^ @@ -2879,12 +5221,22 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = -1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = -1; x = -1; } + ^ + + */ + error(""" + void foo() { void x = -1; x = -1; } + """) } @Test def test_conf24_3() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = 1l; ^ @@ -2892,12 +5244,22 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = 1l; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = 1l; x = 1l; } + ^ + + */ + error(""" + void foo() { void x = 1l; x = 1l; } + """) } @Test def test_conf24_4() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = 0xa4; ^ @@ -2905,12 +5267,22 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = 0xa4; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = 0xa4; x = 0xa4; } + ^ + + */ + error(""" + void foo() { void x = 0xa4; x = 0xa4; } + """) } @Test def test_conf24_5() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = 0.2; ^ @@ -2918,13 +5290,23 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = 0.2; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = 0.2; x = 0.2; } + ^ + + */ + error(""" + void foo() { void x = 0.2; x = 0.2; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf24_6() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = "0.2"; ^ @@ -2932,13 +5314,29 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = "0.2"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = "0.2"; x = "0.2"; } + ^ +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { void x = "0.2"; x = "0.2"; } + ^ +test.c:1:46: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { void x = "0.2"; x = "0.2"; } + ^ + + */ + error(""" + void foo() { void x = "0.2"; x = "0.2"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf24_7() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = &"foo"; ^ @@ -2946,13 +5344,29 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = &"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = &"foo"; x = &"foo"; } + ^ +test.c:1:37: warning: initialization makes integer from pointer without a cast [enabled by default] + void foo() { void x = &"foo"; x = &"foo"; } + ^ +test.c:1:47: warning: assignment makes integer from pointer without a cast [enabled by default] + void foo() { void x = &"foo"; x = &"foo"; } + ^ + + */ + error(""" + void foo() { void x = &"foo"; x = &"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf24_8() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = *"foo"; ^ @@ -2960,16 +5374,26 @@ test.c:1:15: error: variable 'x' has initializer but incomplete type error(""" void x = *"foo"; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = *"foo"; x = *"foo"; } + ^ + + */ + error(""" + void foo() { void x = *"foo"; x = *"foo"; } + """) } @Ignore("initializers are not analyzed precisely enough") @Test def test_conf24_9() { /* gcc reports: -test.c:1:15: error: variable 'x' has initializer but incomplete type +test.c:1:15: error: variable ‘x’ has initializer but incomplete type void x = &1; ^ -test.c:1:24: error: lvalue required as unary '&' operand +test.c:1:24: error: lvalue required as unary ‘&’ operand void x = &1; ^ @@ -2977,6 +5401,22 @@ test.c:1:24: error: lvalue required as unary '&' operand error(""" void x = &1; """) + /* gcc reports: +test.c: In function ‘foo’: +test.c:1:33: error: variable or field ‘x’ declared void + void foo() { void x = &1; x = &1; } + ^ +test.c:1:37: error: lvalue required as unary ‘&’ operand + void foo() { void x = &1; x = &1; } + ^ +test.c:1:45: error: lvalue required as unary ‘&’ operand + void foo() { void x = &1; x = &1; } + ^ + + */ + error(""" + void foo() { void x = &1; x = &1; } + """) } diff --git a/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generator/VarInitializerTestGenerator.scala b/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generator/VarInitializerTestGenerator.scala index c8cc72d10..92752031b 100644 --- a/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generator/VarInitializerTestGenerator.scala +++ b/CTypeChecker/src/test/scala/de/fosd/typechef/typesystem/generator/VarInitializerTestGenerator.scala @@ -11,27 +11,26 @@ package de.fosd.typechef.typesystem.generator */ object VarInitializerTestGenerator extends App with AbstractGenerator { - def types = ReturnConstantTestGenerator.types + def types = ReturnConstantTestGenerator.types - def constants = ReturnConstantTestGenerator.constants + def constants = ReturnConstantTestGenerator.constants val configSpace = List(Opt(types.size), Opt(constants.size)) override protected def considerWarnings: Boolean = true - var _ignoredTests:Map[String,String] = Map() - override def ignoredTests:Map[String,String]=super.ignoredTests ++ _ignoredTests + var _ignoredTests: Map[String, String] = Map() + override def ignoredTests: Map[String, String] = super.ignoredTests ++ _ignoredTests def genTest(c: Config): List[String] = { val t1 = types(c.vals(0)) val c1 = constants(c.vals(1)) - val t = s" $t1 x = $c1;" + val t = s" $t1 x = $c1;" + val u = s" void foo() { $t1 x = $c1; x = $c1; }" - if (c1 startsWith "*") - _ignoredTests += (c.toString -> "initializers are not analyzed precisely enough") - if (c1 startsWith "\"") + if (Set("*", "&", "\"").exists(c1 startsWith _)) _ignoredTests += (c.toString -> "initializers are not analyzed precisely enough") - List(addStructs(t)) + List(addStructs(t), addStructs(u)) }