[cfe-commits] r65360 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Basic/DiagnosticSemaKinds.def lib/AST/Decl.cpp lib/CodeGen/Mangle.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp test/CodeGen/linkage-redecl.c test/Sema/function-redecl.c test/Sema/function.c test/Sema/nested-redef.c test/SemaCXX/function-redecl.cpp

Chris Lattner clattner at apple.com
Mon Feb 23 23:34:26 PST 2009


On Feb 23, 2009, at 5:23 PM, Douglas Gregor wrote:
>  - Don't name-mangle "main"

>
> +++ cfe/trunk/lib/AST/Decl.cpp Mon Feb 23 19:23:02 2009
> @@ -255,6 +255,11 @@
>   return 0;
> }
>
> +bool FunctionDecl::isMain() const {
> +  return getDeclContext()->getLookupContext()->isTranslationUnit() &&
> +    getIdentifier() && getIdentifier()->isStr("main");
> +}

Should this also verify that the linkage isn't static?  Does  
visibility hidden affect determination of main-ness?

/me checks....

Ok, it looks like GCC rejects this:

t.cc:2: error: cannot declare ‘::main’ to be static

But clang is missing that diagnostic.

-Chris





More information about the cfe-commits mailing list