This is an archive of the discontinued LLVM Phabricator instance.

[C++] Add the "norecurse" attribute to main() if in C++ mode
ClosedPublic

Authored by jmolloy on Nov 12 2015, 7:29 AM.

Details

Reviewers
aaron.ballman
Summary

The C++ spec (3.6.1.3) says "The function main shall not be used within a program". This implies that it cannot recurse, so add the norecurse attribute to help the midend out a bit.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 40048.Nov 12 2015, 7:29 AM
jmolloy retitled this revision from to [C++] Add the "norecurse" attribute to main() if in C++ mode.
jmolloy updated this object.
jmolloy added a reviewer: aaron.ballman.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: cfe-commits.
jmolloy added inline comments.Nov 12 2015, 7:31 AM
test/CodeGenCXX/main-norecurse.cpp
2

Wow, I managed to forget in my copy-paste from another test to add "| FileCheck %s" here.

I'll update this before committing.

aaron.ballman added inline comments.Nov 12 2015, 7:32 AM
lib/CodeGen/CodeGenFunction.cpp
721

Missing a period at the end of the sentence.

test/CodeGenCXX/main-norecurse.cpp
2

Missing FileCheck?

aaron.ballman accepted this revision.Nov 12 2015, 7:34 AM
aaron.ballman edited edge metadata.

After fixing the FileCheck and grammar issues, LGTM!

This revision is now accepted and ready to land.Nov 12 2015, 7:34 AM
jmolloy updated this revision to Diff 40050.Nov 12 2015, 7:36 AM
jmolloy edited edge metadata.

Hi Aaron,

Thanks, this should all be fixed now.

Cheers,

James

Yup. LG, thanks!

jmolloy closed this revision.Nov 12 2015, 7:38 AM

Thanks Aaron, committed in r252902.