diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-04-08 18:09:35 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-04-08 18:09:35 +0000 |
commit | 0c3f68a025fc9d41a615854c21c6f2363739c066 (patch) | |
tree | 92fdcb27459923ecf6448b366a65496e139d9866 /gcc/cp/decl.c | |
parent | 8ddb5a296eea999c6376f43a643b2baf79cf886a (diff) | |
download | gcc-0c3f68a025fc9d41a615854c21c6f2363739c066.zip gcc-0c3f68a025fc9d41a615854c21c6f2363739c066.tar.gz gcc-0c3f68a025fc9d41a615854c21c6f2363739c066.tar.bz2 |
re PR c++/56871 ([c++11] Specialization of constexpr Templated Function)
/cp
2013-04-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56871
* decl.c (validate_constexpr_redeclaration): Allow an explicit
specialization to be different wrt the constexpr specifier.
/testsuite
2013-04-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56871
* g++.dg/cpp0x/constexpr-specialization.C: New.
From-SVN: r197597
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 70137f4..01804d2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1196,12 +1196,21 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl) if (DECL_DECLARED_CONSTEXPR_P (old_decl) == DECL_DECLARED_CONSTEXPR_P (new_decl)) return true; - if (TREE_CODE (old_decl) == FUNCTION_DECL && DECL_BUILT_IN (old_decl)) + if (TREE_CODE (old_decl) == FUNCTION_DECL) { - /* Hide a built-in declaration. */ - DECL_DECLARED_CONSTEXPR_P (old_decl) - = DECL_DECLARED_CONSTEXPR_P (new_decl); - return true; + if (DECL_BUILT_IN (old_decl)) + { + /* Hide a built-in declaration. */ + DECL_DECLARED_CONSTEXPR_P (old_decl) + = DECL_DECLARED_CONSTEXPR_P (new_decl); + return true; + } + /* 7.1.5 [dcl.constexpr] + Note: An explicit specialization can differ from the template + declaration with respect to the constexpr specifier. */ + if (! DECL_TEMPLATE_SPECIALIZATION (old_decl) + && DECL_TEMPLATE_SPECIALIZATION (new_decl)) + return true; } error ("redeclaration %qD differs in %<constexpr%>", new_decl); error ("from previous declaration %q+D", old_decl); |