diff mbox

[C++] PR 79380

Message ID 5a9ea5c5-6f87-d664-dcf5-ca004a71897b@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Feb. 17, 2017, 1:32 p.m. UTC
... sorry, what I meant to propose uses 
INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P in the check, per the below. 
Both versions pass testing anyway, but the below seems more correct to me.

Thanks again,
Paolo.

////////////////////

Comments

Jason Merrill Feb. 18, 2017, 2:39 a.m. UTC | #1
OK.

On Fri, Feb 17, 2017 at 8:32 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> ... sorry, what I meant to propose uses
> INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P in the check, per the below. Both
> versions pass testing anyway, but the below seems more correct to me.
>
> Thanks again,
> Paolo.
>
> ////////////////////
diff mbox

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 245503)
+++ cp/typeck.c	(working copy)
@@ -1795,6 +1795,12 @@  cxx_alignas_expr (tree e)
 
          the assignment-expression shall be an integral constant
 	 expression.  */
+
+  if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (e)))
+    {
+      error ("%<alignas%> argument has non-integral type %qT", TREE_TYPE (e));
+      return error_mark_node;
+    }
   
   return cxx_constant_value (e);
 }
Index: testsuite/g++.dg/cpp0x/alignas8.C
===================================================================
--- testsuite/g++.dg/cpp0x/alignas8.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/alignas8.C	(working copy)
@@ -0,0 +1,7 @@ 
+// PR c++/79380
+// { dg-do compile { target c++11 } }
+
+template < typename > constexpr int f () {  return 8;  }
+
+// should have been: struct alignas (f<int>()) S {};
+struct alignas (f) S {};  // { dg-error "17:'alignas' argument has non-integral type" }