From patchwork Fri Jun 22 17:18:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 933524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480327-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WyVHp62O"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41C4zj57dDz9s2t for ; Sat, 23 Jun 2018 03:18:56 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=e7BSa9UG1XQeIfxLM0T6eAAPpOOtBuMKB0xN/x37A1EHCvpXFP npk0VDOMGNhp3a7PasuP4Y2J5544vYRK+axMtnS0HK+blj2mzerKYTZ1Fa9BMB7d IKPjAnCqTzWRTPao7AifsbGqUNFAvSzSZbtSAV6kzUh+2O4dUSE2fzSUs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=N8xhKPyHALvWR2QgHu3RVZXn9qM=; b=WyVHp62OOrVtqtgdTPSH YGHQpS8l5b4Bijt5Y66Z224IQJhP/YtzYgxHhQ5C1ckqRQrS8T9dr+PO77FWYScW udMV7wP+3/JuZsF0xlbTH6ZnmPjYTCYm+Jtax/GZtgf5PkfQQN05OFamqfo4Ab+m cItZ/OLxxM+2JBX4iakfGZU= Received: (qmail 105204 invoked by alias); 22 Jun 2018 17:18:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105195 invoked by uid 89); 22 Jun 2018 17:18:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:D*oracle.com, declaring, H*r:Gateway, dg-warning X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Jun 2018 17:18:43 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5MHDdFP081357; Fri, 22 Jun 2018 17:18:41 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2jrp8htw2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 17:18:41 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5MHIfFB002718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 17:18:41 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5MHIeT7001263; Fri, 22 Jun 2018 17:18:40 GMT Received: from [192.168.1.4] (/87.11.64.97) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Jun 2018 10:18:39 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Use declspecs->locations more in grokdeclarator (and grokvardecl) Message-ID: <2ad89f2e-c609-7c1d-75f1-0c4da712d940@oracle.com> Date: Fri, 22 Jun 2018 19:18:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8932 signatures=668703 X-IsSubscribed: yes Hi, this rather straightforward patch simply uses available location information - in the form of declspecs->locations - in diagnostic messages. In order to do that, the information is also propagated to bad_specifiers and mark_inline_variable. Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2018-06-22 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-22 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. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 261891) +++ cp/decl.c (working copy) @@ -8406,13 +8406,15 @@ 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); @@ -8419,9 +8421,11 @@ bad_specifiers (tree 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); @@ -8428,9 +8432,11 @@ bad_specifiers (tree 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); @@ -8437,9 +8443,11 @@ bad_specifiers (tree 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); Index: testsuite/g++.dg/concepts/locations1.C =================================================================== --- testsuite/g++.dg/concepts/locations1.C (nonexistent) +++ testsuite/g++.dg/concepts/locations1.C (working copy) @@ -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." } Index: testsuite/g++.dg/cpp0x/locations1.C =================================================================== --- testsuite/g++.dg/cpp0x/locations1.C (nonexistent) +++ testsuite/g++.dg/cpp0x/locations1.C (working copy) @@ -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." } Index: testsuite/g++.dg/cpp1z/inline-var2.C =================================================================== --- testsuite/g++.dg/cpp1z/inline-var2.C (revision 261891) +++ testsuite/g++.dg/cpp1z/inline-var2.C (working copy) @@ -1,22 +1,22 @@ // { 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 } } @@ -23,35 +23,35 @@ const int S::var3; // { dg-error "redefinition 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" } Index: testsuite/g++.dg/cpp1z/inline-var3.C =================================================================== --- testsuite/g++.dg/cpp1z/inline-var3.C (revision 261891) +++ testsuite/g++.dg/cpp1z/inline-var3.C (working copy) @@ -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