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 __has_{cpp_}attribute with -traditional-cpp (PR preprocessor/65238)


On Fri, Mar 20, 2015 at 12:30:44PM -0400, Jason Merrill wrote:
> On 03/11/2015 03:10 PM, Jakub Jelinek wrote:
> >__has_{cpp_,}attribute builtin macros are effectively function-like macros
> >taking one argument (and the ISO preprocessor expands macros in the argument
> >which is IMHO desirable), but the traditional preprocessor has been crashing
> >on them or reporting errors.
> 
> Why do we want ISO preprocessor behavior in this specific situation?

You mean that we would handle
#define U unused
#if __has_attribute(U)
int u __attribute__((unused));
#endif
differently between ISO and traditional preprocessing?
That would be surprising to users.  IMHO either we want to expand
the arguments in both cases (what the patch does), or in none
(that would be then consistent with clang++, guess would mean adding
pfile->state.prevent_expansion++; / pfile->state.prevent_expansion--;
pair around something in the ISO case, and would slightly but not too much
simplify the traditional __has_attribute handling; still we'd need to build
the buffer with the argument and feed it to the langhook, which parses it
with ISO preprocessor with disabled expansion).

	Jakub


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