Menu

#137 dropping type declaration attributes

Bug
closed-fixed
nobody
None
5
2015-03-02
2013-06-06
TheBeaNerd
No

CIL seems to be dropping attributes on type declarations. See attached files.
(.cil output generated using cil-1.6.0 with options -c and --keepunused)

For what it is worth:

http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html

says:

"You may specify type attributes in an enum, struct or union type declaration or definition, or for other types in a typedef declaration. "

-- test.c --

__attribute__((x)) struct foo __attribute__((y));

__attribute__((a)) struct foo {
  int a;
} __attribute__((b));

-- test.cil --

/* Generated by CIL v. 1.6.0 */
/* print_CIL_Input is true */

#line 2 "test.c"
struct foo;
#line 2
struct foo;
#line 4 "test.c"
struct foo {
   int a ;
} __attribute__((__b__, __a__)) ;

Related

Bugs: #137

Discussion

  • Gabriel Kerneis

    Gabriel Kerneis - 2014-05-27

    This would be easy to fix, it is only a pretty-printing issue --- CIL has the exact same internal representation for declarations and definitions, we just need to adjust the pretty-printing for GCompTagDecl. I'll try and push it if it does not break the test suite (however, I would feel more confident if you could provide a real-world use-case of attributes applied to type declarations).

     
    • TheBeaNerd

      TheBeaNerd - 2014-05-28

      If CIL is retaining the attributes associated with the type declarations
      and we could
      print it out .. that would be OK.

      I had sort of expected the annotations associated with the declaration to
      be merged into
      the definition .. in much the same way CIL merges attributes on variable
      declarations.

      The example I provided is essentially what I was trying to accomplish ..
      with the
      attribute names changed to protect the innocent. What would you like to
      see in a
      different example?

      On Tue, May 27, 2014 at 4:39 AM, Gabriel Kerneis kerneis@users.sf.netwrote:

      This would be easy to fix, it is only a pretty-printing issue --- CIL has
      the exact same internal representation for declarations and definitions, we
      just need to adjust the pretty-printing for GCompTagDecl. I'll try and push
      it if it does not break the test suite (however, I would feel more
      confident if you could provide a real-world use-case of attributes applied
      to type declarations).


      Status: open
      Group: Bug
      Created: Thu Jun 06, 2013 02:02 PM UTC by TheBeaNerd
      Last Updated: Thu Jun 06, 2013 02:02 PM UTC
      Owner: nobody

      CIL seems to be dropping attributes on type declarations. See attached
      files.
      (.cil output generated using cil-1.6.0 with options -c and --keepunused)

      For what it is worth:

      http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html

      says:

      "You may specify type attributes in an enum, struct or union type
      declaration or definition, or for other types in a typedef declaration. "

      -- test.c --
      attribute((x)) struct foo attribute((y));
      attribute((a)) struct foo {
      int a;} attribute((b));
      -- test.cil --
      / Generated by CIL v. 1.6.0 // print_CIL_Input is true /

      line 2 "test.c"struct foo;#line 2struct foo;#line 4 "test.c"struct foo {

      int a ;} attribute((b, a)) ;


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cil/bugs/137/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #137

      • Gabriel Kerneis

        Gabriel Kerneis - 2014-05-28

        Hmm, it looks like I overlooked the actual issue in my patch, namely that the merge of attributes fails indeed somehow to preserve all of them.

        I'll try and fix it tomorrow, thanks for your feedback.

        Gabriel

         
  • Gabriel Kerneis

    Gabriel Kerneis - 2014-05-27
    • status: open --> closed-fixed
     
  • Gabriel Kerneis

    Gabriel Kerneis - 2014-05-29

    This should now be fully fixed in df7c9ad (by merging attributes indeed).

    Let me know if it behaves as you expect. Thanks for the report.

     
    • TheBeaNerd

      TheBeaNerd - 2014-05-30

      That is fantastic. Thanks, Gabriel!

      When do you expect the next release?

      Dave

      On Thu, May 29, 2014 at 10:48 AM, Gabriel Kerneis kerneis@users.sf.net
      wrote:

      This should now be fully fixed in df7c9ad (by merging attributes indeed).

      Let me know if it behaves as you expect. Thanks for the report.

      Status: closed-fixed
      Group: Bug
      Created: Thu Jun 06, 2013 02:02 PM UTC by TheBeaNerd
      Last Updated: Tue May 27, 2014 10:02 AM UTC
      Owner: nobody

      CIL seems to be dropping attributes on type declarations. See attached
      files.
      (.cil output generated using cil-1.6.0 with options -c and --keepunused)

      For what it is worth:

      http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html

      says:

      "You may specify type attributes in an enum, struct or union type
      declaration or definition, or for other types in a typedef declaration. "

      -- test.c --
      attribute((x)) struct foo attribute((y));
      attribute((a)) struct foo {
      int a;} attribute((b));
      -- test.cil --
      / Generated by CIL v. 1.6.0 // print_CIL_Input is true /

      line 2 "test.c"struct foo;#line 2struct foo;#line 4 "test.c"struct foo {

      int a ;} attribute((b, a)) ;


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cil/bugs/137/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #137


Log in to post a comment.