[C++] Use declspecs->locations more in grokdeclarator (and grokvardecl)

Message ID 2ad89f2e-c609-7c1d-75f1-0c4da712d940@oracle.com
State New
Headers show
Series
  • [C++] Use declspecs->locations more in grokdeclarator (and grokvardecl)
Related show

Commit Message

Paolo Carlini June 22, 2018, 5:18 p.m.
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  <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-22  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.

Comments

Jason Merrill June 22, 2018, 6:45 p.m. | #1
OK.

On Fri, Jun 22, 2018 at 1:18 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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.

>

> ///////////////////

>

Patch

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 %<virtual%> variable", object);
+	  error_at (locations[ds_virtual],
+		    "%qD declared as a %<virtual%> variable", object);
 	if (quals)
 	  error ("%<const%> and %<volatile%> 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 %<virtual%> parameter", object);
+	  error_at (locations[ds_virtual],
+		    "%qD declared as a %<virtual%> parameter", object);
 	if (inlinep)
-	  error ("%qD declared as an %<inline%> parameter", object);
+	  error_at (locations[ds_inline],
+		    "%qD declared as an %<inline%> parameter", object);
 	if (quals)
 	  error ("%<const%> and %<volatile%> 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 %<virtual%> type", object);
+	  error_at (locations[ds_virtual],
+		    "%qD declared as a %<virtual%> type", object);
 	if (inlinep)
-	  error ("%qD declared as an %<inline%> type", object);
+	  error_at (locations[ds_inline],
+		    "%qD declared as an %<inline%> type", object);
 	if (quals)
 	  error ("%<const%> and %<volatile%> 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 %<virtual%> field", object);
+	  error_at (locations[ds_virtual],
+		    "%qD declared as a %<virtual%> field", object);
 	if (inlinep)
-	  error ("%qD declared as an %<inline%> field", object);
+	  error_at (locations[ds_inline],
+		    "%qD declared as an %<inline%> field", object);
 	if (quals)
 	  error ("%<const%> and %<volatile%> 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 %<concept%>");
+          error_at (declspecs->locations[ds_concept],
+		    "a non-template variable cannot be %<concept%>");
           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 ("%<inline%> specifier invalid for variable "
-	     "%qD declared at block scope", decl);
+      error_at (loc, "%<inline%> 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 ("%<concept%> cannot appear in a typedef declaration");
+      error_at (declspecs->locations[ds_concept],
+		"%<concept%> cannot appear in a typedef declaration");
       return error_mark_node;
     }
 
   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;
     }
 
@@ -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 %<concept%>");
+	error_at (declspecs->locations[ds_concept],
+		  "a parameter cannot be declared %<concept%>");
       /* 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 %<constexpr%>");
+          error_at (declspecs->locations[ds_constexpr],
+		    "a parameter cannot be declared %<constexpr%>");
           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 %<virtual%>");
 			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 %<virtual%> inside a union",
-			   unqualified_id);
+		    error_at (declspecs->locations[ds_virtual],
+			      "function %qD declared %<virtual%> 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 %<virtual%>, since it "
-			   "is always static", unqualified_id);
+		    error_at (declspecs->locations[ds_virtual],
+			      "%qD cannot be declared %<virtual%>, 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 %<concept%>");
+                    error_at (declspecs->locations[ds_concept],
+			      "a destructor cannot be %<concept%>");
                     return error_mark_node;
                   }
                 if (constexpr_p)
                   {
-                    error ("a destructor cannot be %<constexpr%>");
+                    error_at (declspecs->locations[ds_constexpr],
+			      "a destructor cannot be %<constexpr%>");
                     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 %<concept%>");
+		  error_at (declspecs->locations[ds_concept],
+			    "a constructor cannot be %<concept%>");
 		  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 %<concept%>",
-			   unqualified_id);
+		  error_at (declspecs->locations[ds_concept],
+			    "static data member %qE declared %<concept%>",
+			    unqualified_id);
 		else if (constexpr_p && !initialized)
 		  {
 		    error ("%<constexpr%> 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 %<concept%>",
-			 unqualified_id);
+		  error_at (declspecs->locations[ds_concept],
+			    "non-static data member %qE declared %<concept%>",
+			    unqualified_id);
                 else if (constexpr_p)
 		  {
-		    error ("non-static data member %qE declared %<constexpr%>",
-			   unqualified_id);
+		    error_at (declspecs->locations[ds_constexpr],
+			      "non-static data member %qE declared %<constexpr%>",
+			      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, 
 		       "%<static%> specifier invalid for function %qs "
 		       "declared out of global scope", name);
 	    else
-	      pedwarn (input_location, OPT_Wpedantic, 
+	      pedwarn (declspecs->locations[ds_inline], OPT_Wpedantic, 
 		       "%<inline%> 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 <typename A, typename B, typename C>
 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<A, B, C>::var36;
 template <int N>
 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 N>
 int Z<N>::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 <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 }
-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 <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 }
-  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>
 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