summaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-03 16:48:24 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-03 16:48:24 +0000
commit29eac75f5e8993789af9161ceacfcbe5a6f2f1d7 (patch)
tree15dd87ec43d36e873c009b43af78a0aa2e569fb3 /gcc/cp/semantics.c
parent18f98733d0d1abcbe3b5c12302e62611ee182fb1 (diff)
downloadgcc-29eac75f5e8993789af9161ceacfcbe5a6f2f1d7.tar.gz
* decl.c (start_decl): Complain about static/thread_local vars
in constexpr function. (check_for_uninitialized_const_var): Also uninitialized vars. * parser.c (cp_parser_jump_statement): And gotos. (cp_parser_asm_operand_list): And asm. (cp_parser_try_block): And try. * semantics.c (ensure_literal_type_for_constexpr_object): And non-literal. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215863 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6c6a5c88214..5d1aafc1f2c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7537,7 +7537,9 @@ tree
ensure_literal_type_for_constexpr_object (tree decl)
{
tree type = TREE_TYPE (decl);
- if (VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl)
+ if (VAR_P (decl)
+ && (DECL_DECLARED_CONSTEXPR_P (decl)
+ || var_in_constexpr_fn (decl))
&& !processing_template_decl)
{
tree stype = strip_array_types (type);
@@ -7546,8 +7548,12 @@ ensure_literal_type_for_constexpr_object (tree decl)
when we try to initialize the variable. */;
else if (!literal_type_p (type))
{
- error ("the type %qT of constexpr variable %qD is not literal",
- type, decl);
+ if (DECL_DECLARED_CONSTEXPR_P (decl))
+ error ("the type %qT of constexpr variable %qD is not literal",
+ type, decl);
+ else
+ error ("variable %qD of non-literal type %qT in %<constexpr%> "
+ "function", decl, type);
explain_non_literal_class (type);
return NULL;
}