+2009-11-16 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32056
+ * decl.h (enum decl_context): Add TPARM enumerator.
+ * decl.c (grokdeclarator): Per 14.1/2, error out if a storage class
+ is specified in a template parameter declaration.
+ * parser.c (cp_parser_template_parameter): Call grokdeclarator with
+ TPARM as third argument.
+
2009-11-13 Jason Merrill <jason@redhat.com>
PR c++/27425
try to parse.
PARM for a parameter declaration (either within a function prototype
or before a function body). Make a PARM_DECL, or return void_type_node.
+ TPARM for a template parameter declaration.
CATCHPARM for a parameter declaration before a catch clause.
TYPENAME if for a typename (in a cast or sizeof).
Don't make a DECL node; just return the ..._TYPE node.
FIELD for a struct or union field; make a FIELD_DECL.
BITFIELD for a field with specified width.
+
INITIALIZED is as for start_decl.
ATTRLIST is a pointer to the list of attributes, which may be NULL
bool type_was_error_mark_node = false;
bool parameter_pack_p = declarator? declarator->parameter_pack_p : false;
bool template_type_arg = false;
+ bool template_parm_flag = false;
bool constexpr_p = declspecs->specs[(int) ds_constexpr];
const char *errmsg;
bitfield = 1, decl_context = FIELD;
else if (decl_context == TEMPLATE_TYPE_ARG)
template_type_arg = true, decl_context = TYPENAME;
+ else if (decl_context == TPARM)
+ template_parm_flag = true, decl_context = PARM;
if (initialized > 1)
funcdef_flag = true;
error ("typedef declaration invalid in parameter declaration");
return error_mark_node;
}
+ else if (template_parm_flag && storage_class != sc_none)
+ {
+ error ("storage class specified for template parameter %qs", name);
+ return error_mark_node;
+ }
else if (storage_class == sc_static
|| storage_class == sc_extern
|| thread_p)
{ NORMAL, /* Ordinary declaration */
FUNCDEF, /* Function definition */
PARM, /* Declaration of parm before function body */
+ TPARM, /* Declaration of template parm */
CATCHPARM, /* Declaration of catch parm */
FIELD, /* Declaration inside struct or union */
BITFIELD, /* Likewise but with specified width */
parm = grokdeclarator (parameter_declarator->declarator,
¶meter_declarator->decl_specifiers,
- PARM, /*initialized=*/0,
+ TPARM, /*initialized=*/0,
/*attrlist=*/NULL);
if (parm == error_mark_node)
return error_mark_node;
+2009-11-16 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32056
+ * testsuite/g++.dg/template/error44.C: New.
+
2009-11-16 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.c-torture/execute/pr41919.c: Mark chars explicitely as signed.
--- /dev/null
+// PR c++/32056
+
+template <auto int T> struct A {}; // { dg-error "storage class specified" }
+template <extern int T> struct B {}; // { dg-error "storage class specified" }
+template <static int T> struct C {}; // { dg-error "storage class specified" }
+template <register int T> struct D {}; // { dg-error "storage class specified" }
+template <mutable int T> struct E {}; // { dg-error "storage class specified" }