From be68f3fa0f47e42f436a574e733ea709a83c6312 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 23 Jun 2018 07:32:45 +0000 Subject: [PATCH] decl.c (bad_specifiers): Add const location_t* parameter and use locations in error messages about... /cp 2018-06-23 Paolo Carlini * 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 * 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 --- gcc/cp/ChangeLog | 12 +++ gcc/cp/decl.c | 109 +++++++++++++-------- gcc/testsuite/ChangeLog | 7 ++ gcc/testsuite/g++.dg/concepts/locations1.C | 15 +++ gcc/testsuite/g++.dg/cpp0x/locations1.C | 29 ++++++ gcc/testsuite/g++.dg/cpp1z/inline-var2.C | 78 +++++++-------- gcc/testsuite/g++.dg/cpp1z/inline-var3.C | 24 ++--- 7 files changed, 181 insertions(+), 93 deletions(-) create mode 100644 gcc/testsuite/g++.dg/concepts/locations1.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/locations1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ae2fd618c19..aec8eb79b7d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2018-06-23 Paolo Carlini + + * 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 PR c++/86219 - ICE with erroneous initializer in template. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b763b257c33..c04b9b7d457 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8406,40 +8406,48 @@ bad_specifiers (tree object, int quals, int inlinep, int friendp, - int raises) + int raises, + const location_t* locations) { switch (type) { case BSP_VAR: if (virtualp) - error ("%qD declared as a % variable", object); + error_at (locations[ds_virtual], + "%qD declared as a % variable", object); if (quals) error ("% and % function specifiers on " "%qD invalid in variable declaration", object); break; case BSP_PARM: if (virtualp) - error ("%qD declared as a % parameter", object); + error_at (locations[ds_virtual], + "%qD declared as a % parameter", object); if (inlinep) - error ("%qD declared as an % parameter", object); + error_at (locations[ds_inline], + "%qD declared as an % parameter", object); if (quals) error ("% and % function specifiers on " "%qD invalid in parameter declaration", object); break; case BSP_TYPE: if (virtualp) - error ("%qD declared as a % type", object); + error_at (locations[ds_virtual], + "%qD declared as a % type", object); if (inlinep) - error ("%qD declared as an % type", object); + error_at (locations[ds_inline], + "%qD declared as an % type", object); if (quals) error ("% and % function specifiers on " "%qD invalid in type declaration", object); break; case BSP_FIELD: if (virtualp) - error ("%qD declared as a % field", object); + error_at (locations[ds_virtual], + "%qD declared as a % field", object); if (inlinep) - error ("%qD declared as an % field", object); + error_at (locations[ds_inline], + "%qD declared as an % field", object); if (quals) error ("% and % function specifiers on " "%qD invalid in field declaration", object); @@ -9254,7 +9262,8 @@ grokvardecl (tree type, { if (!processing_template_decl) { - error ("a non-template variable cannot be %"); + error_at (declspecs->locations[ds_concept], + "a non-template variable cannot be %"); return NULL_TREE; } else @@ -9920,18 +9929,17 @@ check_var_type (tree identifier, tree type) /* Handle declaring DECL as an inline variable. */ static void -mark_inline_variable (tree decl) +mark_inline_variable (tree decl, location_t loc) { bool inlinep = true; if (! toplevel_bindings_p ()) { - error ("% specifier invalid for variable " - "%qD declared at block scope", decl); + error_at (loc, "% specifier invalid for variable " + "%qD declared at block scope", decl); inlinep = false; } else if (cxx_dialect < cxx17) - pedwarn (DECL_SOURCE_LOCATION (decl), 0, - "inline variables are only available " + pedwarn (loc, 0, "inline variables are only available " "with -std=c++17 or -std=gnu++17"); if (inlinep) { @@ -10375,13 +10383,15 @@ grokdeclarator (const cp_declarator *declarator, if (concept_p && typedef_p) { - error ("% cannot appear in a typedef declaration"); + error_at (declspecs->locations[ds_concept], + "% cannot appear in a typedef declaration"); return error_mark_node; } if (constexpr_p && typedef_p) { - error ("% cannot appear in a typedef declaration"); + error_at (declspecs->locations[ds_constexpr], + "% cannot appear in a typedef declaration"); return error_mark_node; } @@ -10485,7 +10495,7 @@ grokdeclarator (const cp_declarator *declarator, "ISO C++ forbids declaration of %qs with no type", name); else warning (OPT_Wreturn_type, - "ISO C++ forbids declaration of %qs with no type", name); + "ISO C++ forbids declaration of %qs with no type", name); if (type_was_error_mark_node && template_parm_flag) /* FIXME we should be able to propagate the error_mark_node as is @@ -10731,12 +10741,14 @@ grokdeclarator (const cp_declarator *declarator, /* Function parameters cannot be concept. */ if (concept_p) - error ("a parameter cannot be declared %"); + error_at (declspecs->locations[ds_concept], + "a parameter cannot be declared %"); /* Function parameters cannot be constexpr. If we saw one, moan and pretend it wasn't there. */ else if (constexpr_p) { - error ("a parameter cannot be declared %"); + error_at (declspecs->locations[ds_constexpr], + "a parameter cannot be declared %"); constexpr_p = 0; } } @@ -11210,7 +11222,7 @@ grokdeclarator (const cp_declarator *declarator, explicitp = 2; if (virtualp) { - permerror (input_location, + permerror (declspecs->locations[ds_virtual], "constructors cannot be declared %"); virtualp = 0; } @@ -11768,7 +11780,8 @@ grokdeclarator (const cp_declarator *declarator, bad_specifiers (decl, BSP_TYPE, virtualp, 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)) /* Acknowledge that this was written: @@ -11974,7 +11987,8 @@ grokdeclarator (const cp_declarator *declarator, bad_specifiers (decl, BSP_PARM, virtualp, memfn_quals != TYPE_UNQUALIFIED, - inlinep, friendp, raises != NULL_TREE); + inlinep, friendp, raises != NULL_TREE, + declspecs->locations); } else if (decl_context == FIELD) { @@ -12061,8 +12075,9 @@ grokdeclarator (const cp_declarator *declarator, ARM 9.5 */ if (virtualp && TREE_CODE (ctype) == UNION_TYPE) { - error ("function %qD declared % inside a union", - unqualified_id); + error_at (declspecs->locations[ds_virtual], + "function %qD declared % inside a union", + unqualified_id); return error_mark_node; } @@ -12070,8 +12085,9 @@ grokdeclarator (const cp_declarator *declarator, && identifier_p (unqualified_id) && IDENTIFIER_NEWDEL_OP_P (unqualified_id)) { - error ("%qD cannot be declared %, since it " - "is always static", unqualified_id); + error_at (declspecs->locations[ds_virtual], + "%qD cannot be declared %, since it " + "is always static", unqualified_id); virtualp = 0; } } @@ -12097,12 +12113,14 @@ grokdeclarator (const cp_declarator *declarator, } if (concept_p) { - error ("a destructor cannot be %"); + error_at (declspecs->locations[ds_concept], + "a destructor cannot be %"); return error_mark_node; } if (constexpr_p) { - error ("a destructor cannot be %"); + error_at (declspecs->locations[ds_constexpr], + "a destructor cannot be %"); return error_mark_node; } } @@ -12116,12 +12134,14 @@ grokdeclarator (const cp_declarator *declarator, if (sfk == sfk_constructor) if (concept_p) { - error ("a constructor cannot be %"); + error_at (declspecs->locations[ds_concept], + "a constructor cannot be %"); return error_mark_node; } 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; } @@ -12248,8 +12268,9 @@ grokdeclarator (const cp_declarator *declarator, VAR_DECL, unqualified_id, type); set_linkage_for_static_data_member (decl); if (concept_p) - error ("static data member %qE declared %", - unqualified_id); + error_at (declspecs->locations[ds_concept], + "static data member %qE declared %", + unqualified_id); else if (constexpr_p && !initialized) { error ("% static data member %qD must have an " @@ -12258,7 +12279,7 @@ grokdeclarator (const cp_declarator *declarator, } if (inlinep) - mark_inline_variable (decl); + mark_inline_variable (decl, declspecs->locations[ds_inline]); if (!DECL_VAR_DECLARED_INLINE_P (decl) && !(cxx_dialect >= cxx17 && constexpr_p)) @@ -12280,12 +12301,14 @@ grokdeclarator (const cp_declarator *declarator, else { if (concept_p) - error ("non-static data member %qE declared %", - unqualified_id); + error_at (declspecs->locations[ds_concept], + "non-static data member %qE declared %", + unqualified_id); else if (constexpr_p) { - error ("non-static data member %qE declared %", - unqualified_id); + error_at (declspecs->locations[ds_constexpr], + "non-static data member %qE declared %", + unqualified_id); constexpr_p = false; } decl = build_decl (input_location, @@ -12320,7 +12343,8 @@ grokdeclarator (const cp_declarator *declarator, bad_specifiers (decl, BSP_FIELD, virtualp, memfn_quals != TYPE_UNQUALIFIED, staticp ? false : inlinep, friendp, - raises != NULL_TREE); + raises != NULL_TREE, + declspecs->locations); } } else if (TREE_CODE (type) == FUNCTION_TYPE @@ -12363,11 +12387,11 @@ grokdeclarator (const cp_declarator *declarator, && pedantic) { if (storage_class == sc_static) - pedwarn (input_location, OPT_Wpedantic, + pedwarn (declspecs->locations[ds_storage_class], OPT_Wpedantic, "% specifier invalid for function %qs " "declared out of global scope", name); else - pedwarn (input_location, OPT_Wpedantic, + pedwarn (declspecs->locations[ds_inline], OPT_Wpedantic, "% specifier invalid for function %qs " "declared out of global scope", name); } @@ -12456,7 +12480,8 @@ grokdeclarator (const cp_declarator *declarator, bad_specifiers (decl, BSP_VAR, virtualp, memfn_quals != TYPE_UNQUALIFIED, - inlinep, friendp, raises != NULL_TREE); + inlinep, friendp, raises != NULL_TREE, + declspecs->locations); if (ctype) { @@ -12489,7 +12514,7 @@ grokdeclarator (const cp_declarator *declarator, } if (inlinep) - mark_inline_variable (decl); + mark_inline_variable (decl, declspecs->locations[ds_inline]); if (innermost_code == cdk_decomp) { gcc_assert (declarator && declarator->kind == cdk_decomp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1b14b01d8a8..01218b3bafd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-06-23 Paolo Carlini + + * 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 PR fortran/86281 diff --git a/gcc/testsuite/g++.dg/concepts/locations1.C b/gcc/testsuite/g++.dg/concepts/locations1.C new file mode 100644 index 00000000000..6e7529b0ee1 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/locations1.C @@ -0,0 +1,15 @@ +// { 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." } diff --git a/gcc/testsuite/g++.dg/cpp0x/locations1.C b/gcc/testsuite/g++.dg/cpp0x/locations1.C new file mode 100644 index 00000000000..6de0368fcbc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/locations1.C @@ -0,0 +1,29 @@ +// { 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." } diff --git a/gcc/testsuite/g++.dg/cpp1z/inline-var2.C b/gcc/testsuite/g++.dg/cpp1z/inline-var2.C index 852531ad258..1a016fa8216 100644 --- a/gcc/testsuite/g++.dg/cpp1z/inline-var2.C +++ b/gcc/testsuite/g++.dg/cpp1z/inline-var2.C @@ -1,57 +1,57 @@ // { dg-do compile { target c++11 } } // { dg-options "-Wdeprecated" } -inline int var1 = 4; // { dg-warning "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 } } +inline int var1 = 4; // { dg-warning "1: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 { - int inline var2; // { dg-warning "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 } } - static inline double var8 = 2.0; // { dg-warning "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 } } + int inline var2; // { dg-warning "7: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 "10: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 { 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 inline double var9 = 3.0; // { dg-warning "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 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 "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-error "redefinition of" "" { target c++14_down } } extern int foo (int); // { dg-warning "redundant redeclaration of" "" { target c++17 } .-1 } extern int bar (int); 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 } } -int inline var13 = foo (1); // { 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 "5:inline variables are only available with" "" { target c++14_down } } struct U { - static inline int var14 = foo (2); // { dg-warning "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 var16 = 4; // { dg-warning "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 inline int var14 = foo (2); // { dg-warning "10: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 "10: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; }; -extern inline int var19; // { dg-warning "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 var19; // { dg-warning "8: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 sz20 = sizeof (var20); 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 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 { - static inline int var24; // { dg-warning "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 int var24; // { dg-warning "10: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 } - static inline int var26 = 5; // { dg-warning "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 double var28 = { 4.0 }; // { dg-warning "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 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 "10: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 "16:inline variables are only available with" "" { target c++14_down } } }; int W::var24; // { dg-error "redefinition of" } const int W::var25; // { dg-error "redefinition of" } @@ -61,23 +61,23 @@ double W::var28; // { dg-error "redefinition of" } double const W::var29; // { dg-error "redefinition of" } 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 -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" } - static inline int var33; // { dg-error "'inline' specifier invalid for variable 'var33' 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 "10:'inline' specifier invalid for variable 'var33' declared at block scope" } return 0; } template 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 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 B; struct C; @@ -88,15 +88,15 @@ C *ptr36 = &Y::var36; template struct Z { - static inline int var37; // { dg-warning "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 int var37; // { dg-warning "10: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 } - static inline int var39 = 5; // { dg-warning "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 double var41 = { 4.0 }; // { dg-warning "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 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 "10: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 "16:inline variables are only available with" "" { target c++14_down } } 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 Z::var37; // { dg-error "redefinition of" } diff --git a/gcc/testsuite/g++.dg/cpp1z/inline-var3.C b/gcc/testsuite/g++.dg/cpp1z/inline-var3.C index 7bee9dc30aa..d3607937780 100644 --- a/gcc/testsuite/g++.dg/cpp1z/inline-var3.C +++ b/gcc/testsuite/g++.dg/cpp1z/inline-var3.C @@ -4,39 +4,39 @@ // aren't emitted into assembly even at -O0. // { dg-final { scan-assembler-not "inlvarvariable" } } -inline int inlvarvariable1 = 1; // { dg-warning "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 } } +inline int inlvarvariable1 = 1; // { dg-warning "1: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 { - int inline inlvarvariable3; // { dg-warning "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 } } + int inline inlvarvariable3; // { dg-warning "7: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 { - 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 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 }; template // { 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 // { 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 { template // { 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 // { 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 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 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 }; #if __cplusplus < 201103L -- 2.30.2