Commit be68f3fa by Paolo Carlini Committed by Paolo Carlini

decl.c (bad_specifiers): Add const location_t* parameter and use locations in…

decl.c (bad_specifiers): Add const location_t* parameter and use locations in error messages about...

/cp
2018-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (bad_specifiers): Add const location_t* parameter and
	use locations in error messages about 'inline' and 'virtual'.
	(mark_inline_variable): Add location_t parameter and use it in
	error_at and pedwarn messages.
	(grokdeclarator): Use declspecs->locations[ds_constexpr],
	declspecs->locations[ds_concept], declspecs->locations[ds_virtual],
	declspecs->locations[ds_inline] in many error messages; adjust
	bad_specifiers and mark_inline_variable calls.
	(grokvardecl): Use declspecs->locations[ds_concept] in error message.

/testsuite
2018-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/concepts/locations1.C: New.
	* g++.dg/cpp0x/locations1.C: Likewise.
	* g++.dg/cpp1z/inline-var2.C: Test locations too.
	* g++.dg/cpp1z/inline-var3.C: Likewise.

From-SVN: r261982
parent 9f8a749e
2018-06-23 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (bad_specifiers): Add const location_t* parameter and
use locations in error messages about 'inline' and 'virtual'.
(mark_inline_variable): Add location_t parameter and use it in
error_at and pedwarn messages.
(grokdeclarator): Use declspecs->locations[ds_constexpr],
declspecs->locations[ds_concept], declspecs->locations[ds_virtual],
declspecs->locations[ds_inline] in many error messages; adjust
bad_specifiers and mark_inline_variable calls.
(grokvardecl): Use declspecs->locations[ds_concept] in error message.
2018-06-22 Jason Merrill <jason@redhat.com> 2018-06-22 Jason Merrill <jason@redhat.com>
PR c++/86219 - ICE with erroneous initializer in template. PR c++/86219 - ICE with erroneous initializer in template.
......
...@@ -8406,40 +8406,48 @@ bad_specifiers (tree object, ...@@ -8406,40 +8406,48 @@ bad_specifiers (tree object,
int quals, int quals,
int inlinep, int inlinep,
int friendp, int friendp,
int raises) int raises,
const location_t* locations)
{ {
switch (type) switch (type)
{ {
case BSP_VAR: case BSP_VAR:
if (virtualp) if (virtualp)
error ("%qD declared as a %<virtual%> variable", object); error_at (locations[ds_virtual],
"%qD declared as a %<virtual%> variable", object);
if (quals) if (quals)
error ("%<const%> and %<volatile%> function specifiers on " error ("%<const%> and %<volatile%> function specifiers on "
"%qD invalid in variable declaration", object); "%qD invalid in variable declaration", object);
break; break;
case BSP_PARM: case BSP_PARM:
if (virtualp) if (virtualp)
error ("%qD declared as a %<virtual%> parameter", object); error_at (locations[ds_virtual],
"%qD declared as a %<virtual%> parameter", object);
if (inlinep) if (inlinep)
error ("%qD declared as an %<inline%> parameter", object); error_at (locations[ds_inline],
"%qD declared as an %<inline%> parameter", object);
if (quals) if (quals)
error ("%<const%> and %<volatile%> function specifiers on " error ("%<const%> and %<volatile%> function specifiers on "
"%qD invalid in parameter declaration", object); "%qD invalid in parameter declaration", object);
break; break;
case BSP_TYPE: case BSP_TYPE:
if (virtualp) if (virtualp)
error ("%qD declared as a %<virtual%> type", object); error_at (locations[ds_virtual],
"%qD declared as a %<virtual%> type", object);
if (inlinep) if (inlinep)
error ("%qD declared as an %<inline%> type", object); error_at (locations[ds_inline],
"%qD declared as an %<inline%> type", object);
if (quals) if (quals)
error ("%<const%> and %<volatile%> function specifiers on " error ("%<const%> and %<volatile%> function specifiers on "
"%qD invalid in type declaration", object); "%qD invalid in type declaration", object);
break; break;
case BSP_FIELD: case BSP_FIELD:
if (virtualp) if (virtualp)
error ("%qD declared as a %<virtual%> field", object); error_at (locations[ds_virtual],
"%qD declared as a %<virtual%> field", object);
if (inlinep) if (inlinep)
error ("%qD declared as an %<inline%> field", object); error_at (locations[ds_inline],
"%qD declared as an %<inline%> field", object);
if (quals) if (quals)
error ("%<const%> and %<volatile%> function specifiers on " error ("%<const%> and %<volatile%> function specifiers on "
"%qD invalid in field declaration", object); "%qD invalid in field declaration", object);
...@@ -9254,7 +9262,8 @@ grokvardecl (tree type, ...@@ -9254,7 +9262,8 @@ grokvardecl (tree type,
{ {
if (!processing_template_decl) if (!processing_template_decl)
{ {
error ("a non-template variable cannot be %<concept%>"); error_at (declspecs->locations[ds_concept],
"a non-template variable cannot be %<concept%>");
return NULL_TREE; return NULL_TREE;
} }
else else
...@@ -9920,18 +9929,17 @@ check_var_type (tree identifier, tree type) ...@@ -9920,18 +9929,17 @@ check_var_type (tree identifier, tree type)
/* Handle declaring DECL as an inline variable. */ /* Handle declaring DECL as an inline variable. */
static void static void
mark_inline_variable (tree decl) mark_inline_variable (tree decl, location_t loc)
{ {
bool inlinep = true; bool inlinep = true;
if (! toplevel_bindings_p ()) if (! toplevel_bindings_p ())
{ {
error ("%<inline%> specifier invalid for variable " error_at (loc, "%<inline%> specifier invalid for variable "
"%qD declared at block scope", decl); "%qD declared at block scope", decl);
inlinep = false; inlinep = false;
} }
else if (cxx_dialect < cxx17) else if (cxx_dialect < cxx17)
pedwarn (DECL_SOURCE_LOCATION (decl), 0, pedwarn (loc, 0, "inline variables are only available "
"inline variables are only available "
"with -std=c++17 or -std=gnu++17"); "with -std=c++17 or -std=gnu++17");
if (inlinep) if (inlinep)
{ {
...@@ -10375,13 +10383,15 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10375,13 +10383,15 @@ grokdeclarator (const cp_declarator *declarator,
if (concept_p && typedef_p) if (concept_p && typedef_p)
{ {
error ("%<concept%> cannot appear in a typedef declaration"); error_at (declspecs->locations[ds_concept],
"%<concept%> cannot appear in a typedef declaration");
return error_mark_node; return error_mark_node;
} }
if (constexpr_p && typedef_p) if (constexpr_p && typedef_p)
{ {
error ("%<constexpr%> cannot appear in a typedef declaration"); error_at (declspecs->locations[ds_constexpr],
"%<constexpr%> cannot appear in a typedef declaration");
return error_mark_node; return error_mark_node;
} }
...@@ -10731,12 +10741,14 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10731,12 +10741,14 @@ grokdeclarator (const cp_declarator *declarator,
/* Function parameters cannot be concept. */ /* Function parameters cannot be concept. */
if (concept_p) if (concept_p)
error ("a parameter cannot be declared %<concept%>"); error_at (declspecs->locations[ds_concept],
"a parameter cannot be declared %<concept%>");
/* Function parameters cannot be constexpr. If we saw one, moan /* Function parameters cannot be constexpr. If we saw one, moan
and pretend it wasn't there. */ and pretend it wasn't there. */
else if (constexpr_p) else if (constexpr_p)
{ {
error ("a parameter cannot be declared %<constexpr%>"); error_at (declspecs->locations[ds_constexpr],
"a parameter cannot be declared %<constexpr%>");
constexpr_p = 0; constexpr_p = 0;
} }
} }
...@@ -11210,7 +11222,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11210,7 +11222,7 @@ grokdeclarator (const cp_declarator *declarator,
explicitp = 2; explicitp = 2;
if (virtualp) if (virtualp)
{ {
permerror (input_location, permerror (declspecs->locations[ds_virtual],
"constructors cannot be declared %<virtual%>"); "constructors cannot be declared %<virtual%>");
virtualp = 0; virtualp = 0;
} }
...@@ -11768,7 +11780,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11768,7 +11780,8 @@ grokdeclarator (const cp_declarator *declarator,
bad_specifiers (decl, BSP_TYPE, virtualp, bad_specifiers (decl, BSP_TYPE, virtualp,
memfn_quals != TYPE_UNQUALIFIED, memfn_quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE); inlinep, friendp, raises != NULL_TREE,
declspecs->locations);
if (decl_spec_seq_has_spec_p (declspecs, ds_alias)) if (decl_spec_seq_has_spec_p (declspecs, ds_alias))
/* Acknowledge that this was written: /* Acknowledge that this was written:
...@@ -11974,7 +11987,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11974,7 +11987,8 @@ grokdeclarator (const cp_declarator *declarator,
bad_specifiers (decl, BSP_PARM, virtualp, bad_specifiers (decl, BSP_PARM, virtualp,
memfn_quals != TYPE_UNQUALIFIED, memfn_quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE); inlinep, friendp, raises != NULL_TREE,
declspecs->locations);
} }
else if (decl_context == FIELD) else if (decl_context == FIELD)
{ {
...@@ -12061,7 +12075,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12061,7 +12075,8 @@ grokdeclarator (const cp_declarator *declarator,
ARM 9.5 */ ARM 9.5 */
if (virtualp && TREE_CODE (ctype) == UNION_TYPE) if (virtualp && TREE_CODE (ctype) == UNION_TYPE)
{ {
error ("function %qD declared %<virtual%> inside a union", error_at (declspecs->locations[ds_virtual],
"function %qD declared %<virtual%> inside a union",
unqualified_id); unqualified_id);
return error_mark_node; return error_mark_node;
} }
...@@ -12070,7 +12085,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12070,7 +12085,8 @@ grokdeclarator (const cp_declarator *declarator,
&& identifier_p (unqualified_id) && identifier_p (unqualified_id)
&& IDENTIFIER_NEWDEL_OP_P (unqualified_id)) && IDENTIFIER_NEWDEL_OP_P (unqualified_id))
{ {
error ("%qD cannot be declared %<virtual%>, since it " error_at (declspecs->locations[ds_virtual],
"%qD cannot be declared %<virtual%>, since it "
"is always static", unqualified_id); "is always static", unqualified_id);
virtualp = 0; virtualp = 0;
} }
...@@ -12097,12 +12113,14 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12097,12 +12113,14 @@ grokdeclarator (const cp_declarator *declarator,
} }
if (concept_p) if (concept_p)
{ {
error ("a destructor cannot be %<concept%>"); error_at (declspecs->locations[ds_concept],
"a destructor cannot be %<concept%>");
return error_mark_node; return error_mark_node;
} }
if (constexpr_p) if (constexpr_p)
{ {
error ("a destructor cannot be %<constexpr%>"); error_at (declspecs->locations[ds_constexpr],
"a destructor cannot be %<constexpr%>");
return error_mark_node; return error_mark_node;
} }
} }
...@@ -12116,12 +12134,14 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12116,12 +12134,14 @@ grokdeclarator (const cp_declarator *declarator,
if (sfk == sfk_constructor) if (sfk == sfk_constructor)
if (concept_p) if (concept_p)
{ {
error ("a constructor cannot be %<concept%>"); error_at (declspecs->locations[ds_concept],
"a constructor cannot be %<concept%>");
return error_mark_node; return error_mark_node;
} }
if (concept_p) if (concept_p)
{ {
error ("a concept cannot be a member function"); error_at (declspecs->locations[ds_concept],
"a concept cannot be a member function");
concept_p = false; concept_p = false;
} }
...@@ -12248,7 +12268,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12248,7 +12268,8 @@ grokdeclarator (const cp_declarator *declarator,
VAR_DECL, unqualified_id, type); VAR_DECL, unqualified_id, type);
set_linkage_for_static_data_member (decl); set_linkage_for_static_data_member (decl);
if (concept_p) if (concept_p)
error ("static data member %qE declared %<concept%>", error_at (declspecs->locations[ds_concept],
"static data member %qE declared %<concept%>",
unqualified_id); unqualified_id);
else if (constexpr_p && !initialized) else if (constexpr_p && !initialized)
{ {
...@@ -12258,7 +12279,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12258,7 +12279,7 @@ grokdeclarator (const cp_declarator *declarator,
} }
if (inlinep) if (inlinep)
mark_inline_variable (decl); mark_inline_variable (decl, declspecs->locations[ds_inline]);
if (!DECL_VAR_DECLARED_INLINE_P (decl) if (!DECL_VAR_DECLARED_INLINE_P (decl)
&& !(cxx_dialect >= cxx17 && constexpr_p)) && !(cxx_dialect >= cxx17 && constexpr_p))
...@@ -12280,11 +12301,13 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12280,11 +12301,13 @@ grokdeclarator (const cp_declarator *declarator,
else else
{ {
if (concept_p) if (concept_p)
error ("non-static data member %qE declared %<concept%>", error_at (declspecs->locations[ds_concept],
"non-static data member %qE declared %<concept%>",
unqualified_id); unqualified_id);
else if (constexpr_p) else if (constexpr_p)
{ {
error ("non-static data member %qE declared %<constexpr%>", error_at (declspecs->locations[ds_constexpr],
"non-static data member %qE declared %<constexpr%>",
unqualified_id); unqualified_id);
constexpr_p = false; constexpr_p = false;
} }
...@@ -12320,7 +12343,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12320,7 +12343,8 @@ grokdeclarator (const cp_declarator *declarator,
bad_specifiers (decl, BSP_FIELD, virtualp, bad_specifiers (decl, BSP_FIELD, virtualp,
memfn_quals != TYPE_UNQUALIFIED, memfn_quals != TYPE_UNQUALIFIED,
staticp ? false : inlinep, friendp, staticp ? false : inlinep, friendp,
raises != NULL_TREE); raises != NULL_TREE,
declspecs->locations);
} }
} }
else if (TREE_CODE (type) == FUNCTION_TYPE else if (TREE_CODE (type) == FUNCTION_TYPE
...@@ -12363,11 +12387,11 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12363,11 +12387,11 @@ grokdeclarator (const cp_declarator *declarator,
&& pedantic) && pedantic)
{ {
if (storage_class == sc_static) if (storage_class == sc_static)
pedwarn (input_location, OPT_Wpedantic, pedwarn (declspecs->locations[ds_storage_class], OPT_Wpedantic,
"%<static%> specifier invalid for function %qs " "%<static%> specifier invalid for function %qs "
"declared out of global scope", name); "declared out of global scope", name);
else else
pedwarn (input_location, OPT_Wpedantic, pedwarn (declspecs->locations[ds_inline], OPT_Wpedantic,
"%<inline%> specifier invalid for function %qs " "%<inline%> specifier invalid for function %qs "
"declared out of global scope", name); "declared out of global scope", name);
} }
...@@ -12456,7 +12480,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12456,7 +12480,8 @@ grokdeclarator (const cp_declarator *declarator,
bad_specifiers (decl, BSP_VAR, virtualp, bad_specifiers (decl, BSP_VAR, virtualp,
memfn_quals != TYPE_UNQUALIFIED, memfn_quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE); inlinep, friendp, raises != NULL_TREE,
declspecs->locations);
if (ctype) if (ctype)
{ {
...@@ -12489,7 +12514,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12489,7 +12514,7 @@ grokdeclarator (const cp_declarator *declarator,
} }
if (inlinep) if (inlinep)
mark_inline_variable (decl); mark_inline_variable (decl, declspecs->locations[ds_inline]);
if (innermost_code == cdk_decomp) if (innermost_code == cdk_decomp)
{ {
gcc_assert (declarator && declarator->kind == cdk_decomp); gcc_assert (declarator && declarator->kind == cdk_decomp);
......
2018-06-23 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/concepts/locations1.C: New.
* g++.dg/cpp0x/locations1.C: Likewise.
* g++.dg/cpp1z/inline-var2.C: Test locations too.
* g++.dg/cpp1z/inline-var3.C: Likewise.
2018-06-22 Paul Thomas <pault@gcc.gnu.org> 2018-06-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/86281 PR fortran/86281
......
// { dg-additional-options "-std=c++17 -fconcepts" }
struct S
{
concept S(); // { dg-error "3:a constructor cannot be .concept." }
concept int s = 1; // { dg-error "3:non-static data member .s. declared .concept." }
concept void foo(); // { dg-error "3:a concept cannot be a member function" }
concept ~S(); // { dg-error "3:a destructor cannot be .concept." }
};
typedef concept int my_int; // { dg-error "9:.concept. cannot appear in a typedef declaration" }
void bar(concept int); // { dg-error "10:a parameter cannot be declared .concept." }
concept int i = 0; // { dg-error "1:a non-template variable cannot be .concept." }
// { dg-do compile { target c++11 } }
void foo()
{
static void bar1(); // { dg-error "3:.static. specifier invalid" }
// { dg-error "3:cannot declare static function" "" { target *-*-* } .-1 }
inline void bar2(); // { dg-error "3:.inline. specifier invalid" }
}
struct S
{
virtual S(); // { dg-error "3:constructors cannot be declared .virtual." }
constexpr int s = 1; // { dg-error "3:non-static data member .s. declared .constexpr." }
constexpr ~S(); // { dg-error "3:a destructor cannot be .constexpr." }
};
typedef constexpr int my_int; // { dg-error "9:.constexpr. cannot appear in a typedef declaration" }
union U
{
virtual void foo(); // { dg-error "3:function .foo. declared .virtual. inside a union" }
};
struct T
{
virtual void operator delete(void*); // { dg-error "3:.operator delete. cannot be declared .virtual." }
};
void bar(constexpr int); // { dg-error "10:a parameter cannot be declared .constexpr." }
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
// { dg-options "-Wdeprecated" } // { dg-options "-Wdeprecated" }
inline int var1 = 4; // { dg-warning "inline variables are only available with" "" { target c++14_down } } inline int var1 = 4; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
static inline int var7 = 9; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var7 = 9; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
namespace N namespace N
{ {
int inline var2; // { dg-warning "inline variables are only available with" "" { target c++14_down } } int inline var2; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
inline const int var6 = 8; // { dg-warning "inline variables are only available with" "" { target c++14_down } } inline const int var6 = 8; // { dg-warning "3:inline variables are only available with" "" { target c++14_down } }
static inline double var8 = 2.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline double var8 = 2.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
extern inline char var10; // { dg-warning "inline variables are only available with" "" { target c++14_down } } extern inline char var10; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
} }
struct S struct S
{ {
static constexpr int var3 = 5; static constexpr int var3 = 5;
static inline int var4 = 6; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var4 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static constexpr int var5 = 7; static constexpr int var5 = 7;
static inline double var9 = 3.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline double var9 = 3.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static constexpr inline int var11 = 11; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static constexpr inline int var11 = 11; // { dg-warning "20:inline variables are only available with" "" { target c++14_down } }
}; };
const int S::var3; // { dg-warning "redundant redeclaration of" "" { target c++17 } } const int S::var3; // { dg-warning "redundant redeclaration of" "" { target c++17 } }
const int S::var3; // { dg-error "redefinition of" "" { target c++14_down } } const int S::var3; // { dg-error "redefinition of" "" { target c++14_down } }
extern int foo (int); // { dg-warning "redundant redeclaration of" "" { target c++17 } .-1 } extern int foo (int); // { dg-warning "redundant redeclaration of" "" { target c++17 } .-1 }
extern int bar (int); extern int bar (int);
struct T { T () { t = foo (3); } T (int x) { t = foo (x); } int t; }; struct T { T () { t = foo (3); } T (int x) { t = foo (x); } int t; };
inline int var12 = foo (0); // { dg-warning "inline variables are only available with" "" { target c++14_down } } inline int var12 = foo (0); // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
int inline var13 = foo (1); // { dg-warning "inline variables are only available with" "" { target c++14_down } } int inline var13 = foo (1); // { dg-warning "5:inline variables are only available with" "" { target c++14_down } }
struct U struct U
{ {
static inline int var14 = foo (2); // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var14 = foo (2); // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline T var15; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline T var15; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline T var16 = 4; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline T var16 = 4; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static int inline var17 = foo (5); // { dg-warning "inline variables are only available with" "" { target c++14_down } } static int inline var17 = foo (5); // { dg-warning "14:inline variables are only available with" "" { target c++14_down } }
static constexpr double var18 = 4.0; static constexpr double var18 = 4.0;
}; };
extern inline int var19; // { dg-warning "inline variables are only available with" "" { target c++14_down } } extern inline int var19; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
extern inline int var20; // { dg-warning "inline variables are only available with" "" { target c++14_down } } extern inline int var20; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
int &ref19 = var19; // { dg-error "odr-used inline variable 'var19' is not defined" "" { target *-*-* } .-2 } int &ref19 = var19; // { dg-error "odr-used inline variable 'var19' is not defined" "" { target *-*-* } .-2 }
int sz20 = sizeof (var20); int sz20 = sizeof (var20);
struct V struct V
{ {
static struct A var21; // { dg-warning "inline variables are only available with" "" { target c++14_down } .+1 } static struct A var21; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .+1 }
static inline struct B var22; // { dg-error "has incomplete type" } static inline struct B var22; // { dg-error "has incomplete type" }
static inline struct C var23 = {}; // { dg-error "has incomplete type" } static inline struct C var23 = {}; // { dg-error "has incomplete type" }
}; // { dg-warning "inline variables are only available with" "" { target c++14_down } .-1 } }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .-1 }
struct W struct W
{ {
static inline int var24; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var24; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline const int var25; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline const int var25; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
// { dg-error "uninitialized const" "" { target *-*-* } .-1 } // { dg-error "uninitialized const" "" { target *-*-* } .-1 }
static inline int var26 = 5; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var26 = 5; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline const int var27 = 6; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline const int var27 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline double var28 = { 4.0 }; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline double var28 = { 4.0 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static const inline double var29 = { 5.0 }; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static const inline double var29 = { 5.0 }; // { dg-warning "16:inline variables are only available with" "" { target c++14_down } }
}; };
int W::var24; // { dg-error "redefinition of" } int W::var24; // { dg-error "redefinition of" }
const int W::var25; // { dg-error "redefinition of" } const int W::var25; // { dg-error "redefinition of" }
...@@ -61,23 +61,23 @@ double W::var28; // { dg-error "redefinition of" } ...@@ -61,23 +61,23 @@ double W::var28; // { dg-error "redefinition of" }
double const W::var29; // { dg-error "redefinition of" } double const W::var29; // { dg-error "redefinition of" }
struct X struct X
{ {
inline int var30; // { dg-error "'var30' declared as an 'inline' field" } inline int var30; // { dg-error "3:'var30' declared as an 'inline' field" }
}; };
inline typedef int TT; // { dg-error "'TT' declared as an 'inline' type" } inline typedef int TT; // { dg-error "1:'TT' declared as an 'inline' type" }
int int
foo (inline int var31) // { dg-error "'var31' declared as an 'inline' parameter" } foo (inline int var31) // { dg-error "6:'var31' declared as an 'inline' parameter" }
{ {
inline int var32; // { dg-error "'inline' specifier invalid for variable 'var32' declared at block scope" } inline int var32; // { dg-error "3:'inline' specifier invalid for variable 'var32' declared at block scope" }
static inline int var33; // { dg-error "'inline' specifier invalid for variable 'var33' declared at block scope" } static inline int var33; // { dg-error "10:'inline' specifier invalid for variable 'var33' declared at block scope" }
return 0; return 0;
} }
template <typename A, typename B, typename C> template <typename A, typename B, typename C>
struct Y struct Y
{ {
static A var34; // { dg-warning "inline variables are only available with" "" { target c++14_down } .+1 } static A var34; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .+1 }
static inline B var35; // { dg-error "has incomplete type" } static inline B var35; // { dg-error "has incomplete type" }
static inline C var36; // { dg-error "has incomplete type" } static inline C var36; // { dg-error "has incomplete type" }
}; // { dg-warning "inline variables are only available with" "" { target c++14_down } .-1 } }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .-1 }
struct A; struct A;
struct B; struct B;
struct C; struct C;
...@@ -88,15 +88,15 @@ C *ptr36 = &Y<A, B, C>::var36; ...@@ -88,15 +88,15 @@ C *ptr36 = &Y<A, B, C>::var36;
template <int N> template <int N>
struct Z struct Z
{ {
static inline int var37; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var37; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline const int var38; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline const int var38; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
// { dg-error "uninitialized const" "" { target *-*-* } .-1 } // { dg-error "uninitialized const" "" { target *-*-* } .-1 }
static inline int var39 = 5; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int var39 = 5; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline const int var40 = 6; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline const int var40 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static inline double var41 = { 4.0 }; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline double var41 = { 4.0 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
static const inline double var42 = { 5.0 }; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static const inline double var42 = { 5.0 }; // { dg-warning "16:inline variables are only available with" "" { target c++14_down } }
static constexpr int var43 = 5; static constexpr int var43 = 5;
static constexpr inline int var44 = 5; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static constexpr inline int var44 = 5; // { dg-warning "20:inline variables are only available with" "" { target c++14_down } }
}; };
template <int N> template <int N>
int Z<N>::var37; // { dg-error "redefinition of" } int Z<N>::var37; // { dg-error "redefinition of" }
......
...@@ -4,39 +4,39 @@ ...@@ -4,39 +4,39 @@
// aren't emitted into assembly even at -O0. // aren't emitted into assembly even at -O0.
// { dg-final { scan-assembler-not "inlvarvariable" } } // { dg-final { scan-assembler-not "inlvarvariable" } }
inline int inlvarvariable1 = 1; // { dg-warning "inline variables are only available with" "" { target c++14_down } } inline int inlvarvariable1 = 1; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
const inline int inlvarvariable2 = 2; // { dg-warning "inline variables are only available with" "" { target c++14_down } } const inline int inlvarvariable2 = 2; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
namespace N namespace N
{ {
int inline inlvarvariable3; // { dg-warning "inline variables are only available with" "" { target c++14_down } } int inline inlvarvariable3; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
const int inline inlvarvariable4 = 4; // { dg-warning "inline variables are only available with" "" { target c++14_down } } const int inline inlvarvariable4 = 4; // { dg-warning "13:inline variables are only available with" "" { target c++14_down } }
} }
struct S struct S
{ {
static inline double inlvarvariable5 = 5.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline double inlvarvariable5 = 5.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
static constexpr int inlvarvariable6 = 6; static constexpr int inlvarvariable6 = 6;
static inline constexpr int inlvarvariable7 = 7; // { dg-warning "inline variables are only available with" "" { target { c++11 && c++14_down } } } static inline constexpr int inlvarvariable7 = 7; // { dg-warning "10:inline variables are only available with" "" { target { c++11 && c++14_down } } }
#endif #endif
}; };
template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
inline int inlvarvariable8; // { dg-warning "inline variables are only available with" "" { target c++14_down } } inline int inlvarvariable8; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
const int inline inlvarvariable9 = 9; // { dg-warning "inline variables are only available with" "" { target c++14_down } } const int inline inlvarvariable9 = 9; // { dg-warning "11:inline variables are only available with" "" { target c++14_down } }
namespace N namespace N
{ {
template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
int inline inlvarvariable10 = 10; // { dg-warning "inline variables are only available with" "" { target c++14_down } } int inline inlvarvariable10 = 10; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
const inline double inlvarvariable11 = 11.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } const inline double inlvarvariable11 = 11.0; // { dg-warning "9:inline variables are only available with" "" { target c++14_down } }
} }
template <int N> template <int N>
struct T struct T
{ {
static inline int inlvarvariable12 = 12; // { dg-warning "inline variables are only available with" "" { target c++14_down } } static inline int inlvarvariable12 = 12; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
static constexpr int inlvarvariable13 = 13; static constexpr int inlvarvariable13 = 13;
static inline constexpr double inlvarvariable14 = 14.0; // { dg-warning "inline variables are only available with" "" { target { c++11 && c++14_down } } } static inline constexpr double inlvarvariable14 = 14.0; // { dg-warning "10:inline variables are only available with" "" { target { c++11 && c++14_down } } }
#endif #endif
}; };
#if __cplusplus < 201103L #if __cplusplus < 201103L
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment