else if (specs->thread_p)
error ("%qs used with %<auto%>",
specs->thread_gnu_p ? "__thread" : "_Thread_local");
+ else if (specs->constexpr_p)
+ /* auto may only be used with another storage class specifier,
+ such as constexpr, if the type is inferred. */
+ error ("%<auto%> used with %<constexpr%>");
else
specs->storage_class = csc_auto;
}
return specs;
}
n = csc_auto;
+ /* auto may only be used with another storage class specifier,
+ such as constexpr, if the type is inferred. */
+ if (specs->constexpr_p)
+ error ("%qE used with %<constexpr%>", scspec);
break;
case RID_EXTERN:
n = csc_extern;
error ("%qE used with %<extern%>", scspec);
else if (specs->storage_class == csc_typedef)
error ("%qE used with %<typedef%>", scspec);
+ else if (specs->storage_class == csc_auto)
+ /* auto may only be used with another storage class specifier,
+ such as constexpr, if the type is inferred. */
+ error ("%qE used with %<auto%>", scspec);
else if (specs->thread_p)
error ("%qE used with %qs", scspec,
specs->thread_gnu_p ? "__thread" : "_Thread_local");
{
constexpr int fv0 = 3;
static_assert (fv0 == 3);
- auto constexpr int fv1 = 4;
+ auto constexpr fv1 = 4;
static_assert (fv1 == 4);
register constexpr float fv2 = 1.0;
- constexpr auto int fv3 = 123;
+ constexpr auto fv3 = 123;
static_assert (fv3 == 123);
constexpr register void *fv4 = (void *) 0;
const int *fv5 = &(constexpr int) { 234 };
constexpr typeof (nullptr) not_npc = nullptr;
int *ptr = 0;
(void) (ptr == not_npc); /* { dg-error "invalid operands" } */
+ /* auto may only be used with another storage class specifier, such as
+ constexpr, if the type is inferred. */
+ auto constexpr int a_c_t = 1; /* { dg-error "'auto' used with 'constexpr'" } */
+ constexpr auto int c_a_t = 1; /* { dg-error "'auto' used with 'constexpr'" } */
+ auto int constexpr a_t_c = 1; /* { dg-error "'constexpr' used with 'auto'" } */
+ constexpr int auto c_t_a = 1; /* { dg-error "'auto' used with 'constexpr'" } */
+ int auto constexpr t_a_c = 1; /* { dg-error "'constexpr' used with 'auto'" } */
+ int constexpr auto t_c_a = 1; /* { dg-error "'auto' used with 'constexpr'" } */
}