[C++] One more cp_expr_loc_or_input_loc

Message ID 38ab63ad-8369-f7a8-10c0-79764c62e3e6@oracle.com
State New
Headers show
Series
  • [C++] One more cp_expr_loc_or_input_loc
Related show

Commit Message

Paolo Carlini Aug. 5, 2019, 9:09 p.m.
Hi,

just spotted an additional error which can benefit from 
cp_expr_loc_or_input_loc. Tested x86_64-linux.

Thanks, Paolo.

////////////////////
/cp
2019-08-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (check_array_designated_initializer): Use
	cp_expr_loc_or_input_loc in one place.

/testsuite
2019-08-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/desig1.C: Check location too.

Comments

Jason Merrill Aug. 5, 2019, 10:31 p.m. | #1
OK.

On Mon, Aug 5, 2019 at 5:09 PM Paolo Carlini <paolo.carlini@oracle.com> wrote:
>

> Hi,

>

> just spotted an additional error which can benefit from

> cp_expr_loc_or_input_loc. Tested x86_64-linux.

>

> Thanks, Paolo.

>

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

>

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 274124)
+++ cp/decl.c	(working copy)
@@ -5520,8 +5520,9 @@  check_array_designated_initializer (constructor_el
 	    sorry ("non-trivial designated initializers not supported");
 	}
       else
-	error ("C99 designator %qE is not an integral constant-expression",
-	       ce->index);
+	error_at (cp_expr_loc_or_input_loc (ce->index),
+		  "C99 designator %qE is not an integral constant-expression",
+		  ce->index);
 
       return false;
     }
Index: testsuite/g++.dg/cpp0x/desig1.C
===================================================================
--- testsuite/g++.dg/cpp0x/desig1.C	(revision 274123)
+++ testsuite/g++.dg/cpp0x/desig1.C	(working copy)
@@ -25,5 +25,5 @@  struct C
   constexpr operator SE() const { return SE::se0; }
 };
 
-int c[] = { [C()] = 0 }; // { dg-error "integral constant-expression" }
+int c[] = { [C()] = 0 }; // { dg-error "14:C99 designator .C\\\(\\\). is not an integral constant-expression" }
 			 // { dg-warning "does not allow C99 designated initializers" "" { target *-*-* } .-1 }