diff mbox

Add a test for C DR#423 (PR c/65471)

Message ID 20160608110251.GA16494@redhat.com
State New
Headers show

Commit Message

Marek Polacek June 8, 2016, 11:02 a.m. UTC
Reading <https://gcc.gnu.org/ml/gcc-patches/2016-05/msg01054.html> it occured
to me that we might resolve c/65471, dealing with type interpretation in
_Generic, too.  Since it turned out that GCC already does the right thing,
I'm only adding a new test.  (We should discard qualifiers from controlling 
expression of _Generic.)

Regarding the bit-field issue, it seems that we should do nothing and keep
it implementation-defined for now.

Tested on x86_64-linux, ok for trunk?

2016-06-08  Marek Polacek  <polacek@redhat.com>

	PR c/65471
	* gcc.dg/c11-generic-3.c: New test.


	Marek

Comments

Joseph Myers June 8, 2016, 8:05 p.m. UTC | #1
On Wed, 8 Jun 2016, Marek Polacek wrote:

> Reading <https://gcc.gnu.org/ml/gcc-patches/2016-05/msg01054.html> it occured
> to me that we might resolve c/65471, dealing with type interpretation in
> _Generic, too.  Since it turned out that GCC already does the right thing,
> I'm only adding a new test.  (We should discard qualifiers from controlling 
> expression of _Generic.)
> 
> Regarding the bit-field issue, it seems that we should do nothing and keep
> it implementation-defined for now.
> 
> Tested on x86_64-linux, ok for trunk?

OK.
diff mbox

Patch

diff --git gcc/testsuite/gcc.dg/c11-generic-3.c gcc/testsuite/gcc.dg/c11-generic-3.c
index e69de29..8bac21e 100644
--- gcc/testsuite/gcc.dg/c11-generic-3.c
+++ gcc/testsuite/gcc.dg/c11-generic-3.c
@@ -0,0 +1,10 @@ 
+/* Test C11 _Generic.  Test we follow the resolution of DR#423.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+char const *a = _Generic ("bla", char *: "");
+char const *b = _Generic ("bla", char[4]: ""); /* { dg-error "not compatible with any association" } */
+char const *c = _Generic ((int const) { 0 }, int: "");
+char const *d = _Generic ((int const) { 0 }, int const: ""); /* { dg-error "not compatible with any association" } */
+char const *e = _Generic (+(int const) { 0 }, int: "");
+char const *f = _Generic (+(int const) { 0 }, int const: ""); /* { dg-error "not compatible with any association" } */