else
{
- if (decl_spec_seq_has_spec_p (declspecs, ds_inline)
- || decl_spec_seq_has_spec_p (declspecs, ds_virtual))
- error ("%qs can only be specified for functions",
- decl_spec_seq_has_spec_p (declspecs, ds_inline)
- ? "inline" : "virtual");
+ if (decl_spec_seq_has_spec_p (declspecs, ds_inline))
+ error_at (declspecs->locations[ds_inline],
+ "%<inline%> can only be specified for functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_virtual))
+ error_at (declspecs->locations[ds_virtual],
+ "%<virtual%> can only be specified for functions");
else if (saw_friend
&& (!current_class_type
|| current_scope () != current_class_type))
- error ("%<friend%> can only be specified inside a class");
+ error_at (declspecs->locations[ds_friend],
+ "%<friend%> can only be specified inside a class");
else if (decl_spec_seq_has_spec_p (declspecs, ds_explicit))
- error ("%<explicit%> can only be specified for constructors");
+ error_at (declspecs->locations[ds_explicit],
+ "%<explicit%> can only be specified for constructors");
else if (declspecs->storage_class)
- error ("a storage class can only be specified for objects "
- "and functions");
- else if (decl_spec_seq_has_spec_p (declspecs, ds_const)
- || decl_spec_seq_has_spec_p (declspecs, ds_volatile)
- || decl_spec_seq_has_spec_p (declspecs, ds_restrict)
- || decl_spec_seq_has_spec_p (declspecs, ds_thread))
- error ("qualifiers can only be specified for objects "
- "and functions");
+ error_at (declspecs->locations[ds_storage_class],
+ "a storage class can only be specified for objects "
+ "and functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_const))
+ error_at (declspecs->locations[ds_const],
+ "%<const%> can only be specified for objects and "
+ "functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_volatile))
+ error_at (declspecs->locations[ds_volatile],
+ "%<volatile%> can only be specified for objects and "
+ "functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_restrict))
+ error_at (declspecs->locations[ds_restrict],
+ "%<__restrict%> can only be specified for objects and "
+ "functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_thread))
+ error_at (declspecs->locations[ds_thread],
+ "%<__thread%> can only be specified for objects "
+ "and functions");
else if (saw_typedef)
- warning (0, "%<typedef%> was ignored in this declaration");
+ warning_at (declspecs->locations[ds_typedef], 0,
+ "%<typedef%> was ignored in this declaration");
else if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr))
- error ("%<constexpr%> cannot be used for type declarations");
+ error_at (declspecs->locations[ds_constexpr],
+ "%<constexpr%> cannot be used for type declarations");
}
if (declspecs->attributes && warn_attributes && declared_type)
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+inline struct A; // { dg-error "1:'inline'" }
+virtual struct B; // { dg-error "1:'virtual'" }
+friend struct C; // { dg-error "1:'friend'" }
+explicit struct D; // { dg-error "1:'explicit'" }
+mutable struct E; // { dg-error "1:a storage class" }
+const struct F; // { dg-error "1:'const'" }
+volatile struct G; // { dg-error "1:'volatile'" }
+__restrict struct H; // { dg-error "1:'__restrict'" }
+__thread struct I; // { dg-error "1:'__thread'" }
+typedef struct J; // { dg-warning "1:'typedef'" }
+constexpr struct K; // { dg-error "1:'constexpr'" }