[cfe-dev] Attribute on constructor parameter rejected

Guillaume Papin guillaume.papin at epitech.eu
Thu Sep 5 12:50:44 PDT 2013


Hum, I updated yesterday so it's quite recent. I tried the following
with both my system-wide install of clang (version 3.2) and the one I
built after my update yesterday:

  [papin_g:~/GSoC/build]$ cat /tmp/gnu-unused.cpp                            
  struct AB {
    AB([[gnu::unused]] int i) {}
    void f([[gnu::unused]] int i) {} // no error for this line
  };
  [papin_g:~/GSoC/build]$ ./bin/clang++ -std=c++11 -fsyntax-only /tmp/gnu-unused.cpp
  /tmp/gnu-unused.cpp:2:6: error: expected member name or ';' after declaration specifiers
    AB([[gnu::unused]] int i) {}
    ~~ ^
  /tmp/gnu-unused.cpp:2:6: error: an attribute list cannot appear here
    AB([[gnu::unused]] int i) {}
       ^~~~~~~~~~~~~~~
  /tmp/gnu-unused.cpp:2:22: error: expected ')'
    AB([[gnu::unused]] int i) {}
                       ^
  /tmp/gnu-unused.cpp:2:5: note: to match this '('
    AB([[gnu::unused]] int i) {}
      ^
  3 errors generated.


I will update Clang tomorrow and see if the problem persists. Maybe it's
only me and I checked out at the wrong time or it's has been fixed since
yesterday.

Aaron Ballman <aaron at aaronballman.com> writes:

> On Thu, Sep 5, 2013 at 11:49 AM, Guillaume Papin
> <guillaume.papin at epitech.eu> wrote:
>> Hi,
>>
>> While testing some code with attributes I found the following that looks
>> like a bug to me:
>>
>>   $ clang-check /tmp/unused.cpp -- -std=c++11
>>
>>   struct AB {
>>     AB([[gnu::unused]] int i) {}
>>     // ^~~~~~~~~~~~~~~ /tmp/unused.cpp:2:5: error: an attribute list cannot appear here
>>
>>     void f([[gnu::unused]] int i) {} // no error for this line
>>   };
>>
>> Do constructors have different parameter-declaration-list than member
>> functions?
>
> They do not -- are you using ToT?  I get no errors with your code on a
> relatively recent build.
>
> ~Aaron
>

-- 
Guillaume Papin




More information about the cfe-dev mailing list