summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0156-PR-c-48657.patch
blob: 8f5cbafaea8492a152e96e865e7db31700512651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 03be58e53f230926009974bd7aed6a40a557dc1d Mon Sep 17 00:00:00 2001
From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Apr 2011 19:39:26 +0000
Subject: [PATCH 156/200] 	PR c++/48657
 	* decl.c (cp_finish_decl): Handle non-member constant variables
 	in templates, too.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172791 138bc75d-0d04-0410-961f-82ee72b054a4

index 41beef3..61b57ea 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5862,11 +5862,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	 then it can be used in future constant expressions, so its value
 	 must be available. */
       if (!(init
-	    && DECL_CLASS_SCOPE_P (decl)
-	    /* We just set TREE_CONSTANT appropriately; see above.  */
-	    && TREE_CONSTANT (decl)
+	    && init_const_expr_p
 	    && !type_dependent_p
-	    /* FIXME non-value-dependent constant expression  */
+	    && decl_maybe_constant_var_p (decl)
 	    && !value_dependent_init_p (init)))
 	{
 	  if (init)
@@ -5878,6 +5876,14 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	  goto finish_end;
 	}
 
+      if (!DECL_CLASS_SCOPE_P (decl))
+	{
+	  tree init_code = check_initializer (decl, init, flags, &cleanup);
+	  if (init_code)
+	    DECL_INITIAL (decl) = init;
+	  goto finish_end;
+	}
+
       if (TREE_CODE (init) == TREE_LIST)
 	{
 	  /* If the parenthesized-initializer form was used (e.g.,
new file mode 100644
index 0000000..6552ec6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/const4.C
@@ -0,0 +1,9 @@
+// PR c++/48657
+
+template<unsigned> struct A { typedef int T; };
+
+template<unsigned> void f()
+{
+  const unsigned D = 4;
+  A<D>::T t;
+}
-- 
1.7.0.4

OpenPOWER on IntegriCloud