]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
7cee35b246e49c3f09f87dca09797ce9b865cff8
[thirdparty/openembedded/openembedded-core-contrib.git] /
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.
7
8 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171667 138bc75d-0d04-0410-961f-82ee72b054a4
9
10 index eb5d4f5..f62f913 100644
11 --- a/gcc/cp/decl2.c
12 +++ b/gcc/cp/decl2.c
13 @@ -1264,6 +1264,25 @@ cp_reconstruct_complex_type (tree type, tree bottom)
14 return cp_build_qualified_type (outer, cp_type_quals (type));
15 }
16
17 +/* Replaces any constexpr expression that may be into the attributes
18 + arguments with their reduced value. */
19 +
20 +static void
21 +cp_check_const_attributes (tree attributes)
22 +{
23 + tree attr;
24 + for (attr = attributes; attr; attr = TREE_CHAIN (attr))
25 + {
26 + tree arg;
27 + for (arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
28 + {
29 + tree expr = TREE_VALUE (arg);
30 + if (EXPR_P (expr))
31 + TREE_VALUE (arg) = maybe_constant_value (expr);
32 + }
33 + }
34 +}
35 +
36 /* Like decl_attributes, but handle C++ complexity. */
37
38 void
39 @@ -1284,6 +1303,8 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
40 return;
41 }
42
43 + cp_check_const_attributes (attributes);
44 +
45 if (TREE_CODE (*decl) == TEMPLATE_DECL)
46 decl = &DECL_TEMPLATE_RESULT (*decl);
47
48 new file mode 100644
49 index 0000000..ac85c07
50 --- /dev/null
51 +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
52 @@ -0,0 +1,63 @@
53 +// { dg-options -std=c++0x }
54 +
55 +//A few constexpr's
56 +constexpr int foo() { return __alignof__(int); }
57 +
58 +template<typename T>
59 +constexpr int fooT() { return __alignof__(T); }
60 +
61 +template<int N>
62 +constexpr int fooN() { return N; }
63 +
64 +//Now the attributes
65 +
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)>())));
70 +
71 +//with variables inside a template,
72 +template <typename T>
73 +void fun()
74 +{
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)>())));
80 +}
81 +
82 +//instantiate it,
83 +void bar()
84 +{
85 + fun<int>();
86 +}
87 +
88 +//with classes
89 +struct __attribute__((aligned(foo()))) S0
90 +{
91 + char dummy;
92 +};
93 +S0 s0;
94 +
95 +struct __attribute__((aligned(fooT<int>()))) S1
96 +{
97 + char dummy;
98 +};
99 +S1 s1;
100 +
101 +//and class templates
102 +template <typename T>
103 +struct __attribute__((aligned(foo()))) S2
104 +{
105 + char dummy;
106 +};
107 +
108 +S2<int> s2;
109 +
110 +template <typename T>
111 +struct __attribute__((aligned(fooT<T>()))) S3
112 +{
113 + char dummy;
114 +};
115 +S3<int> s3;
116 --
117 1.7.0.4
118