1 Upstream-Status: Inappropriate [Backport]
2 From 87e73453e8135e72f592c1d7c84da942e7a1e308 Mon Sep 17 00:00:00 2001
3 From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Tue, 29 Mar 2011 14:24:59 +0000
5 Subject: [PATCH 026/200] * decl2.c (cp_check_const_attributes): New.
6 (cplus_decl_attributes): Call cp_check_const_attributes.
8 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171667 138bc75d-0d04-0410-961f-82ee72b054a4
10 index eb5d4f5..f62f913 100644
13 @@ -1264,6 +1264,25 @@ cp_reconstruct_complex_type (tree type, tree bottom)
14 return cp_build_qualified_type (outer, cp_type_quals (type));
17 +/* Replaces any constexpr expression that may be into the attributes
18 + arguments with their reduced value. */
21 +cp_check_const_attributes (tree attributes)
24 + for (attr = attributes; attr; attr = TREE_CHAIN (attr))
27 + for (arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
29 + tree expr = TREE_VALUE (arg);
31 + TREE_VALUE (arg) = maybe_constant_value (expr);
36 /* Like decl_attributes, but handle C++ complexity. */
39 @@ -1284,6 +1303,8 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
43 + cp_check_const_attributes (attributes);
45 if (TREE_CODE (*decl) == TEMPLATE_DECL)
46 decl = &DECL_TEMPLATE_RESULT (*decl);
49 index 0000000..ac85c07
51 +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
53 +// { dg-options -std=c++0x }
56 +constexpr int foo() { return __alignof__(int); }
59 +constexpr int fooT() { return __alignof__(T); }
62 +constexpr int fooN() { return N; }
66 +//with normal variables,
67 +int a __attribute__((aligned(foo())));
68 +int b __attribute__((aligned(fooT<int>())));
69 +int c __attribute__((aligned(fooN<__alignof__(int)>())));
71 +//with variables inside a template,
72 +template <typename T>
75 + T a __attribute__((aligned(foo())));
76 + T b __attribute__((aligned(fooT<T>())));
77 + T c __attribute__((aligned(fooN<__alignof__(T)>())));
78 + T d __attribute__((aligned(fooT<int>())));
79 + T e __attribute__((aligned(fooN<__alignof__(int)>())));
89 +struct __attribute__((aligned(foo()))) S0
95 +struct __attribute__((aligned(fooT<int>()))) S1
101 +//and class templates
102 +template <typename T>
103 +struct __attribute__((aligned(foo()))) S2
110 +template <typename T>
111 +struct __attribute__((aligned(fooT<T>()))) S3