diff options
author | Jason Merrill <jason@redhat.com> | 2012-11-15 11:11:56 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2012-11-15 11:11:56 -0500 |
commit | c8d15a726285594865c3e827a33f570ed583e7ac (patch) | |
tree | 206b8fd5edfc32a0f670b04f78f7156947ccf813 /gcc | |
parent | f64bcb29f5f44c2d8d4ec722dcd9df6c9c235968 (diff) | |
download | gcc-c8d15a726285594865c3e827a33f570ed583e7ac.zip gcc-c8d15a726285594865c3e827a33f570ed583e7ac.tar.gz gcc-c8d15a726285594865c3e827a33f570ed583e7ac.tar.bz2 |
re PR c++/54903 (Auto + static in-class constant initialization not working)
PR c++/54903
* decl2.c (mark_used): Don't complain about auto in templates.
From-SVN: r193535
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/auto36.C | 18 |
3 files changed, 31 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dc510ab..232822a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-11-14 Jason Merrill <jason@redhat.com> + PR c++/54903 + * decl2.c (mark_used): Don't complain about auto in templates. + PR c++/37276 * decl.c (decls_match): Remove #ifdef around earlier fix. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 90ee16b..9f20757 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4534,8 +4534,8 @@ mark_used (tree decl) it to find out its type. */ if ((decl_maybe_constant_var_p (decl) || (TREE_CODE (decl) == FUNCTION_DECL - && (DECL_DECLARED_CONSTEXPR_P (decl) - || type_uses_auto (TREE_TYPE (TREE_TYPE (decl)))))) + && DECL_DECLARED_CONSTEXPR_P (decl)) + || type_uses_auto (TREE_TYPE (decl))) && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl) && !uses_template_parms (DECL_TI_ARGS (decl))) @@ -4550,6 +4550,14 @@ mark_used (tree decl) --function_depth; } + if (processing_template_decl) + return true; + + /* Check this too in case we're within fold_non_dependent_expr. */ + if (DECL_TEMPLATE_INFO (decl) + && uses_template_parms (DECL_TI_ARGS (decl))) + return true; + if (type_uses_auto (TREE_TYPE (decl))) { error ("use of %qD before deduction of %<auto%>", decl); @@ -4560,14 +4568,6 @@ mark_used (tree decl) if (cp_unevaluated_operand != 0) return true; - if (processing_template_decl) - return true; - - /* Check this too in case we're within fold_non_dependent_expr. */ - if (DECL_TEMPLATE_INFO (decl) - && uses_template_parms (DECL_TI_ARGS (decl))) - return true; - DECL_ODR_USED (decl) = 1; if (DECL_CLONED_FUNCTION_P (decl)) DECL_ODR_USED (DECL_CLONED_FUNCTION (decl)) = 1; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto36.C b/gcc/testsuite/g++.dg/cpp0x/auto36.C new file mode 100644 index 0000000..c353040 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto36.C @@ -0,0 +1,18 @@ +// PR c++/54903 +// { dg-options -std=c++11 } + +template<int N, int D> +struct Modulus +{ + static auto const value = N % D; +}; + +template<int N> +struct Angle +{ + static auto const value = Modulus<N, 360>::value; // ERROR + //static int const value = Modulus<N, 360>::value; // OK + //static auto const value = N % 360; // OK + + typedef Angle<value> type; +}; |