public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
@ 2015-12-31 11:50 Dominik Vogt
  2016-01-02  0:53 ` Martin Sebor
  2016-04-29  9:23 ` [PATCH] " Andreas Krebbel
  0 siblings, 2 replies; 13+ messages in thread
From: Dominik Vogt @ 2015-12-31 11:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

The attached patch fixes C++-11 handling of "alignas(0)" which
should be ignored but currently generates an error message.  A
test case is included; the patch has been tested on S390x.  Since
it's a language issue it should be independent of the backend
used.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69089

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 211 bytes --]

gcc/cp/ChangeLog

	* parser.c (cp_parser_std_attribute_spec): Do not generate an "aligned"
	attribute for "alignas(0)".
gcc/testsuite/ChangeLog

	PR tree-optimization/68069
	* g++.dg/cpp0x/alignas5.C: New test.

[-- Attachment #3: 0001-C-11-Ingore-alignas-0-instead-of-generating-an-error.patch --]
[-- Type: text/x-diff, Size: 2480 bytes --]

From 59787d0af77d0a45dabb06ac7fc70e9bd7a9d5d8 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
Date: Wed, 30 Dec 2015 15:08:52 +0100
Subject: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
 error message.

This is required by the C++-11 standard.
---
 gcc/cp/parser.c                       | 15 +++++++++------
 gcc/testsuite/g++.dg/cpp0x/alignas5.C | 19 +++++++++++++++++++
 2 files changed, 28 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c1948c4..72da56d 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -23990,6 +23990,7 @@ cp_parser_std_attribute_spec (cp_parser *parser)
   else
     {
       tree alignas_expr;
+      int is_int_zero;
 
       /* Look for an alignment-specifier.  */
 
@@ -24026,6 +24027,7 @@ cp_parser_std_attribute_spec (cp_parser *parser)
 	}
 
       alignas_expr = cxx_alignas_expr (alignas_expr);
+      is_int_zero = integer_zerop (alignas_expr);
       alignas_expr = build_tree_list (NULL_TREE, alignas_expr);
 
       if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
@@ -24040,12 +24042,13 @@ cp_parser_std_attribute_spec (cp_parser *parser)
 	  return error_mark_node;
 	}
 
-      /* Build the C++-11 representation of an 'aligned'
-	 attribute.  */
-      attributes =
-	build_tree_list (build_tree_list (get_identifier ("gnu"),
-					  get_identifier ("aligned")),
-			 alignas_expr);
+      if (! is_int_zero)
+	/* Build the C++-11 representation of an 'aligned'
+	   attribute.  */
+	attributes =
+	  build_tree_list (build_tree_list (get_identifier ("gnu"),
+					    get_identifier ("aligned")),
+			   alignas_expr);
     }
 
   return attributes;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
new file mode 100644
index 0000000..0ddbc63
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
@@ -0,0 +1,19 @@
+// PR c++/69089
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-attributes" }
+
+alignas (0) int valid1;
+alignas (1 - 1) int valid2;
+struct Tvalid
+{
+  alignas (0) int i;
+  alignas (2 * 0) int j;
+}
+
+alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
+alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
+struct Tinvalid
+{
+  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
+  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
+};
-- 
2.3.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2015-12-31 11:50 [PATCH] PR/68089: C++-11: Ingore "alignas(0)" Dominik Vogt
@ 2016-01-02  0:53 ` Martin Sebor
  2016-01-04 11:34   ` Dominik Vogt
  2016-04-29  9:23 ` [PATCH] " Andreas Krebbel
  1 sibling, 1 reply; 13+ messages in thread
From: Martin Sebor @ 2016-01-02  0:53 UTC (permalink / raw)
  To: gcc-patches, vogt; +Cc: Andreas Krebbel

On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> The attached patch fixes C++-11 handling of "alignas(0)" which
> should be ignored but currently generates an error message.  A
> test case is included; the patch has been tested on S390x.  Since
> it's a language issue it should be independent of the backend
> used.

The patch doesn't handle value-dependent expressions(*).  It
seems that the problem is in handle_aligned_attribute() calling
check_user_alignment() with the second argument (ALLOW_ZERO)
set to false.  Calling it with true fixes the problem and handles
value-dependent expressions (I haven't done any more testing beyond
that).

Also, in the test, I noticed the definition of the first struct
is missing the terminating semicolon.

Martin

[*] Such as in the following:

   template <int N> struct A { alignas (N) int i; };
   A<0> a3;

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-02  0:53 ` Martin Sebor
@ 2016-01-04 11:34   ` Dominik Vogt
  2016-01-04 16:55     ` Martin Sebor
                       ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-01-04 11:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> >The attached patch fixes C++-11 handling of "alignas(0)" which
> >should be ignored but currently generates an error message.  A
> >test case is included; the patch has been tested on S390x.  Since
> >it's a language issue it should be independent of the backend
> >used.
> 
> The patch doesn't handle value-dependent expressions(*).

> It
> seems that the problem is in handle_aligned_attribute() calling
> check_user_alignment() with the second argument (ALLOW_ZERO)
> set to false.  Calling it with true fixes the problem and handles
> value-dependent expressions (I haven't done any more testing beyond
> that).

Like the attached patch?  (Passes the testsuite on s390x.)

But wouldn't an "aligned" attribute be added, allowing the backend
to possibly generate an error or a warning?

> Also, in the test, I noticed the definition of the first struct
> is missing the terminating semicolon.

Yeah.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 202 bytes --]

gcc/c-family/ChangeLog

	PR/69089
	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
	"aligned" attribute.

gcc/testsuite/ChangeLog

	PR/69089
	* g++.dg/cpp0x/alignas5.C: New test.

[-- Attachment #3: 0001-C-11-Ingore-alignas-0-instead-of-generating-an-error.patch --]
[-- Type: text/x-diff, Size: 2267 bytes --]

From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
Date: Wed, 30 Dec 2015 15:08:52 +0100
Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
 error message.

This is required by the C++-11 standard.
---
 gcc/c-family/c-common.c               |  2 +-
 gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 653d1dc..9eb25a9 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
   else if (TYPE_P (*node))
     type = node, is_type = 1;
 
-  if ((i = check_user_alignment (align_expr, false)) == -1
+  if ((i = check_user_alignment (align_expr, true)) == -1
       || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
     *no_add_attrs = true;
   else if (is_type)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
new file mode 100644
index 0000000..f3252a9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
@@ -0,0 +1,29 @@
+// PR c++/69089
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-attributes" }
+
+alignas (0) int valid1;
+alignas (1 - 1) int valid2;
+struct Tvalid
+{
+  alignas (0) int i;
+  alignas (2 * 0) int j;
+};
+
+alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
+alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
+struct Tinvalid
+{
+  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
+  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
+};
+
+template <int N> struct TNvalid1 { alignas (N) int i; };
+TNvalid1<0> SNvalid1;
+template <int N> struct TNvalid2 { alignas (N) int i; };
+TNvalid2<1 - 1> SNvalid2;
+
+template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
+TNinvalid1<-1> SNinvalid1;
+template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
+TNinvalid2<1 - 2> SNinvalid2;
-- 
2.3.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
@ 2016-01-04 16:55     ` Martin Sebor
  2016-02-05 16:29     ` [PING, PATCH] " Dominik Vogt
                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Martin Sebor @ 2016-01-04 16:55 UTC (permalink / raw)
  To: vogt; +Cc: gcc-patches, Andreas Krebbel

On 01/04/2016 04:33 AM, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
>> On 12/31/2015 04:50 AM, Dominik Vogt wrote:
>>> The attached patch fixes C++-11 handling of "alignas(0)" which
>>> should be ignored but currently generates an error message.  A
>>> test case is included; the patch has been tested on S390x.  Since
>>> it's a language issue it should be independent of the backend
>>> used.
>>
>> The patch doesn't handle value-dependent expressions(*).
>
>> It
>> seems that the problem is in handle_aligned_attribute() calling
>> check_user_alignment() with the second argument (ALLOW_ZERO)
>> set to false.  Calling it with true fixes the problem and handles
>> value-dependent expressions (I haven't done any more testing beyond
>> that).
>
> Like the attached patch?  (Passes the testsuite on s390x.)

Yes, like that (though someone other than me needs to approve
your patch).

>
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?

AFAICS, both the C and C++ front ends ignore the attribute
when check_user_alignment() returns -1 (either on error or
when the requested alignment is zero and ALLOW_ZERO is true).

Martin

PS I wonder what it is about this thread that makes my email
client (Thunderbird) include only gcc-patches and krebbel
when I hit Reply All and not you.  (I had to manually add
your email.)  It looks like your reply back to me did the
same thing.

Martin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
  2016-01-04 16:55     ` Martin Sebor
@ 2016-02-05 16:29     ` Dominik Vogt
  2016-02-22 11:57     ` [PING 2, " Dominik Vogt
                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-02-05 16:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel, Martin Sebor

Can this be approved?

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69089

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 2, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
  2016-01-04 16:55     ` Martin Sebor
  2016-02-05 16:29     ` [PING, PATCH] " Dominik Vogt
@ 2016-02-22 11:57     ` Dominik Vogt
  2016-03-02  6:36     ` [PING 3, " Dominik Vogt
                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-02-22 11:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 3, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
                       ` (2 preceding siblings ...)
  2016-02-22 11:57     ` [PING 2, " Dominik Vogt
@ 2016-03-02  6:36     ` Dominik Vogt
  2016-03-15  6:12     ` [PING 4, " Dominik Vogt
                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-03-02  6:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 4, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
                       ` (3 preceding siblings ...)
  2016-03-02  6:36     ` [PING 3, " Dominik Vogt
@ 2016-03-15  6:12     ` Dominik Vogt
  2016-04-05  9:43     ` [PING 5, " Dominik Vogt
                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-03-15  6:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 5, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
                       ` (4 preceding siblings ...)
  2016-03-15  6:12     ` [PING 4, " Dominik Vogt
@ 2016-04-05  9:43     ` Dominik Vogt
  2016-04-28  3:46       ` Jeff Law
  2016-04-12  9:04     ` [PING 6, " Dominik Vogt
  2016-04-27  7:35     ` [PING 7, " Dominik Vogt
  7 siblings, 1 reply; 13+ messages in thread
From: Dominik Vogt @ 2016-04-05  9:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 6, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
                       ` (5 preceding siblings ...)
  2016-04-05  9:43     ` [PING 5, " Dominik Vogt
@ 2016-04-12  9:04     ` Dominik Vogt
  2016-04-27  7:35     ` [PING 7, " Dominik Vogt
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-04-12  9:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 7, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-01-04 11:34   ` Dominik Vogt
                       ` (6 preceding siblings ...)
  2016-04-12  9:04     ` [PING 6, " Dominik Vogt
@ 2016-04-27  7:35     ` Dominik Vogt
  7 siblings, 0 replies; 13+ messages in thread
From: Dominik Vogt @ 2016-04-27  7:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
> > On 12/31/2015 04:50 AM, Dominik Vogt wrote:
> > >The attached patch fixes C++-11 handling of "alignas(0)" which
> > >should be ignored but currently generates an error message.  A
> > >test case is included; the patch has been tested on S390x.  Since
> > >it's a language issue it should be independent of the backend
> > >used.
> > 
> > The patch doesn't handle value-dependent expressions(*).
> 
> > It
> > seems that the problem is in handle_aligned_attribute() calling
> > check_user_alignment() with the second argument (ALLOW_ZERO)
> > set to false.  Calling it with true fixes the problem and handles
> > value-dependent expressions (I haven't done any more testing beyond
> > that).
> 
> Like the attached patch?  (Passes the testsuite on s390x.)
> 
> But wouldn't an "aligned" attribute be added, allowing the backend
> to possibly generate an error or a warning?
> 
> > Also, in the test, I noticed the definition of the first struct
> > is missing the terminating semicolon.
> 
> Yeah.

> gcc/c-family/ChangeLog
> 
> 	PR/69089
> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
> 	"aligned" attribute.
> 
> gcc/testsuite/ChangeLog
> 
> 	PR/69089
> 	* g++.dg/cpp0x/alignas5.C: New test.

> >From 2461293b9070da74950fd0ae055d1239cc69ce67 Mon Sep 17 00:00:00 2001
> From: Dominik Vogt <vogt@de.ibm.com>
> Date: Wed, 30 Dec 2015 15:08:52 +0100
> Subject: [PATCH] C++-11: Ingore "alignas(0)" instead of generating an
>  error message.
> 
> This is required by the C++-11 standard.
> ---
>  gcc/c-family/c-common.c               |  2 +-
>  gcc/testsuite/g++.dg/cpp0x/alignas5.C | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 653d1dc..9eb25a9 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -7804,7 +7804,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
>    else if (TYPE_P (*node))
>      type = node, is_type = 1;
>  
> -  if ((i = check_user_alignment (align_expr, false)) == -1
> +  if ((i = check_user_alignment (align_expr, true)) == -1
>        || !check_cxx_fundamental_alignment_constraints (*node, i, flags))
>      *no_add_attrs = true;
>    else if (is_type)
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> new file mode 100644
> index 0000000..f3252a9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C
> @@ -0,0 +1,29 @@
> +// PR c++/69089
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wno-attributes" }
> +
> +alignas (0) int valid1;
> +alignas (1 - 1) int valid2;
> +struct Tvalid
> +{
> +  alignas (0) int i;
> +  alignas (2 * 0) int j;
> +};
> +
> +alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
> +alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
> +struct Tinvalid
> +{
> +  alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
> +  alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
> +};
> +
> +template <int N> struct TNvalid1 { alignas (N) int i; };
> +TNvalid1<0> SNvalid1;
> +template <int N> struct TNvalid2 { alignas (N) int i; };
> +TNvalid2<1 - 1> SNvalid2;
> +
> +template <int N> struct TNinvalid1 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid1<-1> SNinvalid1;
> +template <int N> struct TNinvalid2 { alignas (N) int i; }; /* { dg-error "not a positive power of 2" } */
> +TNinvalid2<1 - 2> SNinvalid2;
> -- 
> 2.3.0
> 



Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PING 5, PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2016-04-05  9:43     ` [PING 5, " Dominik Vogt
@ 2016-04-28  3:46       ` Jeff Law
  0 siblings, 0 replies; 13+ messages in thread
From: Jeff Law @ 2016-04-28  3:46 UTC (permalink / raw)
  To: vogt, gcc-patches, Andreas Krebbel

On 04/05/2016 03:43 AM, Dominik Vogt wrote:
> On Mon, Jan 04, 2016 at 12:33:21PM +0100, Dominik Vogt wrote:
>> On Fri, Jan 01, 2016 at 05:53:08PM -0700, Martin Sebor wrote:
>>> On 12/31/2015 04:50 AM, Dominik Vogt wrote:
>>>> The attached patch fixes C++-11 handling of "alignas(0)" which
>>>> should be ignored but currently generates an error message.  A
>>>> test case is included; the patch has been tested on S390x.  Since
>>>> it's a language issue it should be independent of the backend
>>>> used.
>>>
>>> The patch doesn't handle value-dependent expressions(*).
>>
>>> It
>>> seems that the problem is in handle_aligned_attribute() calling
>>> check_user_alignment() with the second argument (ALLOW_ZERO)
>>> set to false.  Calling it with true fixes the problem and handles
>>> value-dependent expressions (I haven't done any more testing beyond
>>> that).
>>
>> Like the attached patch?  (Passes the testsuite on s390x.)
>>
>> But wouldn't an "aligned" attribute be added, allowing the backend
>> to possibly generate an error or a warning?
>>
>>> Also, in the test, I noticed the definition of the first struct
>>> is missing the terminating semicolon.
>>
>> Yeah.
>
>> gcc/c-family/ChangeLog
>>
>> 	PR/69089
>> 	* c-common.c (handle_aligned_attribute): Allow 0 as an argument to the
>> 	"aligned" attribute.
>>
>> gcc/testsuite/ChangeLog
>>
>> 	PR/69089
>> 	* g++.dg/cpp0x/alignas5.C: New test.
OK for the trunk.
jeff

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
  2015-12-31 11:50 [PATCH] PR/68089: C++-11: Ingore "alignas(0)" Dominik Vogt
  2016-01-02  0:53 ` Martin Sebor
@ 2016-04-29  9:23 ` Andreas Krebbel
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Krebbel @ 2016-04-29  9:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: vogt

On 12/31/2015 12:50 PM, Dominik Vogt wrote:
> The attached patch fixes C++-11 handling of "alignas(0)" which
> should be ignored but currently generates an error message.  A
> test case is included; the patch has been tested on S390x.  Since
> it's a language issue it should be independent of the backend
> used.
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69089

Applied. Thanks!

-Andreas-


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-04-29  9:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-31 11:50 [PATCH] PR/68089: C++-11: Ingore "alignas(0)" Dominik Vogt
2016-01-02  0:53 ` Martin Sebor
2016-01-04 11:34   ` Dominik Vogt
2016-01-04 16:55     ` Martin Sebor
2016-02-05 16:29     ` [PING, PATCH] " Dominik Vogt
2016-02-22 11:57     ` [PING 2, " Dominik Vogt
2016-03-02  6:36     ` [PING 3, " Dominik Vogt
2016-03-15  6:12     ` [PING 4, " Dominik Vogt
2016-04-05  9:43     ` [PING 5, " Dominik Vogt
2016-04-28  3:46       ` Jeff Law
2016-04-12  9:04     ` [PING 6, " Dominik Vogt
2016-04-27  7:35     ` [PING 7, " Dominik Vogt
2016-04-29  9:23 ` [PATCH] " Andreas Krebbel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).