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]

[C++ Patch] PR 82466 ("Missing warning for re-declaration of built-in function as variable")


Hi,

this issue filed by Bernd is sort-of a small follow-up to his c++/71973: the C front-end already warns for things like:

    int printf;

where we are declaring in the global namespace a built-in. Beyond copying over to the C++ front-end the code already existing in the C front-end, there are a couple of nits: 1- We probably want to enable suppressing the warning, give it a name, for this I'm overloading the name already added by Bernd for c++/71973 (using it in the C front-end too, without changes to the default behavior, seems a very safe tweak to me); 2- as a pure C++ nit, we probably want to take into account namespaces, thus the additional check CP_DECL_CONTEXT (newdecl) == global_namespace and the new C++ test (for a couple of hours I had in the tree CP_DECL_CONTEXT (newdecl) == CP_DECL_CONTEXT (olddecl), probably unnecessarily more verbose!?). What else? A couple of existing C++ testcases needed rather obvious adjusting, note in particular g++.old-deja/g++.mike/p811.C, which has flattened in the global namespace a declaration 'extern ostream clog;', which, were in namespace std, as per the standard, would not trigger the new warning, even if 'clog' is also the name of a math builtin, thanks to the additional check mentioned above. Tested x86_64.

Thanks, Paolo.

//////////////////

Attachment: CL_82466
Description: Text document

Attachment: patch_82466
Description: Text document


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