This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/21686: Broken quotation in error message


Volker Reichelt <reichelt@igpm.rwth-aachen.de> writes:

| On mainline and the 4.0 branch we get the error message
| 
|   PR21686.cc: In constructor 'foo()::A::A()':
|   PR21686.cc:4: error: use of %<auto%> variable from containing function
|   PR21686.cc:3: error:   'int i' declared here
| 
| for the code snippet
| 
|   void foo()
|   {
|       int i;
|       struct A { A() { i; } };
|   }
| 
| Note the broken quotation of "auto". This is due to the following code
| in cp/semantics.c:
| 
|   error ("use of %s from containing function",
| 	 (TREE_CODE (decl) == VAR_DECL
| 	  ? "%<auto%> variable" : "parameter"));
| 
| The quotation with %< %> just doesn't work in strings substituted by %s.
| The attached patch fixes the quotation by not using substitution.
| The error message then reads as expected:
| 
|   PR21686.cc: In constructor 'foo()::A::A()':
|   PR21686.cc:4: error: use of 'auto' variable from containing function
|   PR21686.cc:3: error:   'int i' declared here

And it is more suitable for translation -- we should avoid those kinds of
substituion in the C++ front-end.

| Bootstrapped and regtested on i686-pc-linux-gnu.
| OK for 4.0 branch and mainline?

As far as I'm concerned, it is OK.

| Should I wait for the unslushing of mainline, although this is a regression?

As I understand mainline is blocked only for non-regression fixes.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]