1 From 87e73453e8135e72f592c1d7c84da942e7a1e308 Mon Sep 17 00:00:00 2001
2 From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Tue, 29 Mar 2011 14:24:59 +0000
4 Subject: [PATCH 026/200] * decl2.c (cp_check_const_attributes): New.
5 (cplus_decl_attributes): Call cp_check_const_attributes.
7 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171667 138bc75d-0d04-0410-961f-82ee72b054a4
9 index eb5d4f5..f62f913 100644
12 @@ -1264,6 +1264,25 @@ cp_reconstruct_complex_type (tree type, tree bottom)
13 return cp_build_qualified_type (outer, cp_type_quals (type));
16 +/* Replaces any constexpr expression that may be into the attributes
17 + arguments with their reduced value. */
20 +cp_check_const_attributes (tree attributes)
23 + for (attr = attributes; attr; attr = TREE_CHAIN (attr))
26 + for (arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
28 + tree expr = TREE_VALUE (arg);
30 + TREE_VALUE (arg) = maybe_constant_value (expr);
35 /* Like decl_attributes, but handle C++ complexity. */
38 @@ -1284,6 +1303,8 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
42 + cp_check_const_attributes (attributes);
44 if (TREE_CODE (*decl) == TEMPLATE_DECL)
45 decl = &DECL_TEMPLATE_RESULT (*decl);
48 index 0000000..ac85c07
50 +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
52 +// { dg-options -std=c++0x }
55 +constexpr int foo() { return __alignof__(int); }
58 +constexpr int fooT() { return __alignof__(T); }
61 +constexpr int fooN() { return N; }
65 +//with normal variables,
66 +int a __attribute__((aligned(foo())));
67 +int b __attribute__((aligned(fooT<int>())));
68 +int c __attribute__((aligned(fooN<__alignof__(int)>())));
70 +//with variables inside a template,
71 +template <typename T>
74 + T a __attribute__((aligned(foo())));
75 + T b __attribute__((aligned(fooT<T>())));
76 + T c __attribute__((aligned(fooN<__alignof__(T)>())));
77 + T d __attribute__((aligned(fooT<int>())));
78 + T e __attribute__((aligned(fooN<__alignof__(int)>())));
88 +struct __attribute__((aligned(foo()))) S0
94 +struct __attribute__((aligned(fooT<int>()))) S1
100 +//and class templates
101 +template <typename T>
102 +struct __attribute__((aligned(foo()))) S2
109 +template <typename T>
110 +struct __attribute__((aligned(fooT<T>()))) S3